rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.27k stars 180 forks source link

Skip non selectable items #456

Open b3ngg opened 2 years ago

b3ngg commented 2 years ago

closes #404

This prevents the selection of non selectable item when searching a select field and using the arrow keys. This improves the user experience when searching for example in a group select without isGroupHeaderSelectable enabled as the first item is directly selected and no additional arrow key usage is required.

For this reason I added two new functions for manipulating the hoverItemIndex that incorporate a mechanism for skipping non selectable items. One for setting to a specific index and one for incrementing or decrementing the index.

I used the the new methods in a few places, however, due to my lack of overview of the codebase, I am not sure if it fits in all places.

PS: Sorry I opened #455 by accident.

rob-balfre commented 2 years ago

@b3ngg thanks for the PR. Got 15 failing tests with these changes though.

b3ngg commented 2 years ago

@rob-balfre Whoops, sorry. Unfortunately the tests are not working for me locally. I try to get them working when I've got some time.