Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search input becomes permanently disabled after directional key press #1230

Closed
britishboop opened this issue Nov 17, 2024 · 0 comments · Fixed by #1242
Closed

Search input becomes permanently disabled after directional key press #1230

britishboop opened this issue Nov 17, 2024 · 0 comments · Fixed by #1242
Labels

Comments

@britishboop
Copy link

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:

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?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant