mskocik / svelecte

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

Visual selected state does not get reset when select is cleared #257

Closed jochienabuurs closed 3 days ago

jochienabuurs commented 1 month ago

When using the keyboard to select a value from a select, the visually selected state (managed by adding a .sv-dd-item-active class) does not get reset when the select is cleared.

See the first example: https://svelecte-v5.vercel.app/examples#multiselect

Steps to reproduce:

Even when using highlightFirstItem={false} and disableHighlight={true} this behavior does not change.

Am I missing something? Do i manually need to remove the class altogether when no value is selected?

mskocik commented 1 month ago
  • Notice that "Fuchsia" visually has a selected state, even though it's not actually selected.

Actually it's "active" (active by keyboard/hovered by mouse) state. Colors for "selected" and "active" items are slightly different, but "active" state has higher priority that "selected" see screenshot: image

If you repeat your steps, but before clearing fuchsia navigate to another item, you will see it works as it should

jochienabuurs commented 4 weeks ago

Thank you for the reply. Sorry for not using the correct terms. I meant the active state. I would expect the active state to be reset when all the input values are cleared.

I suppose this behaviour is intended, so I'm curious as to why this is working the way it does. I hope you find the time to explain.

mskocik commented 4 weeks ago

You need to understand, we are talking about very specific example here (https://svelecte-v5.vercel.app/examples#multiselect) with specific combination of properties (keepSelectionInList + collapseSelection="always") where even some keyboard action doesn't work (Backspace and Ctrl+Backspace).

This is default behavior:

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 3 days.