tom-select icon indicating copy to clipboard operation
tom-select copied to clipboard

`selectOnTab` does not set focus to next field

Open mixable opened this issue 1 year ago • 3 comments

Describe the bug When using the option selectOnTab, the focus is not set to the next input. To jump to the next input, an additional 'tab' is necessary.

To Reproduce The behavior could be seen on any TomSelect instance:

  1. Create a simple TomSelect and set selectOnTab option to true
  2. Click on a select input to open the dropdown
  3. Select an option by using the up/down keys
  4. Use the 'TAB' key to select the option
  5. Result: the dropdown closes and the focus stays on the current input
  6. One more 'TAB' sets the focus to the next input

Expected behavior When I press TAB on an input, the focus should go to the next input because my selection is done. Except for a multi-select input, in this case, using TAB with selectOnTab enabled, the focus should stay on the input.

Selectize is also using this behavior, which is much more intuitive and user friendly. For single selects, the user already finalized his input with the TAB and will definitely go to the next step / the next input. So it's not necessary to require another TAB.

Additional context The reason for this is the preventDefault(e) on line 739 in the onKeyDown method for KEY_TAB. I would suggest to check for a multi-select input and only call preventDefault(e) if we have one. Otherwise, do not call preventDefault(e) to jump to the next input.

mixable avatar Aug 09 '23 08:08 mixable

This issue has not been active in 120 days and has been marked "stale". Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Dec 08 '23 02:12 github-actions[bot]

I think that it's more an UX issue than a bug, but it sure is a bothersome one 😆

I'll try to check if the preventDefault is the only thing we need to change it

DNA avatar Dec 22 '23 17:12 DNA

This issue has not been active in 120 days and has been marked "stale". Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Apr 21 '24 02:04 github-actions[bot]