Multi-select retains first item when clear_button plugin is enabled #724
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When you've enabled the
clear_button
plugin and have a multi-select dropdown that allows you to "activate" the items (i.e. not using theno_active_items
plugin), pressing the keyboard shortcut for selecting everything (Ctrl+A, Cmd+A, etc) followed by backspace results in the first item in the list being retained. The list appears empty visually but the clear button is still visible while it should only appear when there are selected items, plus the first item is not selectable anymore (due to using the default setting forhideSelected
).The problem does not occur if you actually use the clear button, or if you remove all the items one by one (by simply holding backspace for example).
This seems to be due these pieces of code (added some comments for clarification):
The clear button simply calls a
clear()
function instead of removing a range of items one by one, like how it works when you "activate" all the items and press backspace. Removing items one by one targets every item specifically so it's no problem either.Since you're already in the context of
removeItem()
, I don't think there will be any side effects by simply havingnodeIndex()
target the.item
class.