Fermain / -mollify

9 stars 9 forks source link

Refactors keyboard navigation code block #124

Closed Melisa-Zorraindo closed 11 months ago

Melisa-Zorraindo commented 11 months ago

I made a minor improvement to the navigateSearchResults(). Previously, the function attempted to scroll the selected search result into view by checking its position in the DOM and then scrolling based on that position. I had logged the position to the console to check if the element was visible or not, and hardcoded the position in an if statement to implement the functionality. That obviously wasn't a perfect approach since any changes to the search bar's placement in the DOM would have broken the scrolling behaviour.

However, I realised that I didn't need the position at all. I removed the if statements, and now the scrolling into view is handled by one small block of code that scrolls up or down, as opposed to the previous two separate blocks for scrolling up and down.

It looks like I've made more changes than I actually did, but they're only indentation.