Skip to content

Cannot tab out of input after closing suggestions #831

@richardscarrott

Description

@richardscarrott

I have a close button inside the suggestions container which, onMouseDown blurs the input in order to close the suggestions. It however breaks the ability to tab around inside the form; the user get's stuck in the autocomplete input.

Test in Chrome and Safari for Mac OS.

https://codepen.io/riscarrott/pen/zYdvpYm

  1. Focus on 'Name' input
  2. Type "Test"
  3. Tab to 'Language' input
  4. Click 'Close' button
  5. Tab to 'Age' input
  6. Tab back to 'Language' input (shift + tab)
  7. Tab to 'Age' input again

EXPECT: Age input to be in focus
ACTUAL: 'Language' input remains in focus; cannot tab out of 'Language' input without first blurring with mouse

I've not been able to get to the bottom of it as it's hard without stepping through the code but of course this causes it to blur, but I'm sure somebody with existing knowledge of the various events and state would have a good idea; my guess is it's something to do with the justClickedOnSuggestionsContainer state.

react-autosuggest-tab-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions