aaranxu / adidoks

AdiDoks is a mordern documentation theme, which is a port of the Hugo theme Doks for Zola.
https://adidoks.org
MIT License
228 stars 82 forks source link

Only capture arrow key events when search suggestions are visible #22

Closed ajyoon closed 2 years ago

ajyoon commented 2 years ago

The previous code unconditionally captured up and down arrow keys for use in search result navigation. This change fixes this by making the search code only capture arrow keys when search results are visible and present.

The apparently redundant check for 'd-none' and focusableSuggestions length is needed because suggestions can still exist when the user enters a search term with matches but then clicks out of the search box while leaving the search term in it.

Fixes #21

aaranxu commented 2 years ago

Thanks so much!