wire-elements / spotlight

Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
MIT License
911 stars 71 forks source link

Reset selected index to 0 when filtering search #83

Closed manuelsteiner closed 2 years ago

manuelsteiner commented 2 years ago

Hi,

would it make sense to reset the selected index in the js file to 0 after searching for a command or dependency?

Scenario A user starts typing and, scrolls up and down in provided list and then continues typing to narrow the search.

Outcome In case the selected index is now out of bounds of the search result list, nothing is highlighted and you need to hit up to reach a selected item.

Improvement Would it make sense to have a deterministic behaviour as in either the index gets reset to 0 after reach search or alternatively if the current selected index is out of bounds of the search result list at least?

I am open to create a PR if you'd like and we agree on an implementation.

PhiloNL commented 2 years ago

That makes sense; I think it's good to reset the selected index to 0. If you want to open a PR, that would be great. Thanks!