mskocik / svelecte

Flexible autocomplete/select component written in Svelte,
https://svelecte.vercel.app
MIT License
469 stars 42 forks source link

Is it possible to search when an item is already selected? #201

Closed thearchitect3344 closed 8 months ago

thearchitect3344 commented 1 year ago

I wasn't able to get the search function to work when I have already selected an item on svelecte that does not have multiple enabled. It appears that I have to deselect the item via backspace in order to search for a new item. Is it possible to allow searching items while an item is already selected? It would be nice to be able to search for the new item without having to clear out the select every time. A use case for this could be a select that already has an item pre-selected, but we want to allow the user to quickly, easily change it without having to clear it out first.

mskocik commented 1 year ago

This behaviour is intentional, because otherwise user can think it is a multiselect. I am not sure I want to support this use case. Because this use case - selecting different item when other is selected is possible, only without keyboard search.

thearchitect3344 commented 1 year ago

This behaviour is intentional, because otherwise user can think it is a multiselect. I am not sure I want to support this use case. Because this use case - selecting different item when other is selected is possible, only without keyboard search.

Thanks for your reply. I see your point about thinking it could be a multiselect, but, I think that is alleviated since they would have had to have a single selection done first. It would be nice to have some way to select via keyboard search. The case I needed it in had a lot of options and scrolling to select became kind of cumbersome.

mskocik commented 1 year ago

You can always remove current selection by pressing Backspace or Delete on your keyboard before starting the search

Jojoshua commented 1 year ago

@mskocik IMO this is a poor workaround. If the component claims to be searchable but the user has to hit backspace first that is a bad experience. Could this behavior be allowed if it was known to be a single select?

mskocik commented 1 year ago

@mskocik IMO this is a poor workaround. If the component claims to be searchable but the user has to hit backspace first that is a bad experience. Could this behavior be allowed if it was known to be a single select?

Maybe it can (not sooner than v4). Not sure about required code changes and especially edge cases if there will be any.