Skip to content

Search input becomes permanently disabled after directional key press #1230

@britishboop

Description

@britishboop

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions