-
Notifications
You must be signed in to change notification settings - Fork 638
Description
Describe the bug
It's possible to end up with the search input being disabled with no way to re-enable it if a directional key press is used to show the dropdown or is the last keypress before the dropdown is closed/input is blurred progmatically.
To Reproduce
- Tab focus to the single select input on: https://choices-js.github.io/Choices/
- Press the down arrow key to open the input
- Find you are unable to type in the input, and can't restore the ability to without refreshing the page.
(It's possible to type one character from this point if that character is used to open the dropdown as that keypress is handled separately).
Expected behavior
Searching is possible irregardless of the key used to open the dropdown.
Choices version and bundle
- Present on at least 10.2.0 and 11.0.2
Desktop:
- OS: Windows
- Browser: Firefox, Chrome
- Version 132.0.1, 131.0.6778.70
Additional context
It looks to be a result of _canSearch being set to false in the _onDirectionalKey method here:
Choices/src/scripts/choices.ts
Line 1775 in a127f82
| this._canSearch = false; |
I think this is because _canSearch is only set to true again in the onKeyUp handler which is bound to the input element. Removing this line seems to sort the issue.
I'm not sure whether this would have any side effects - perhaps unnecessary searches in the onInput handler?
Choices/src/scripts/choices.ts
Line 1662 in a127f82
| if (this._canSearch) { |
I don't know if it's possible for an input event to be triggered from up/down/page up/page down though.