tom-select
tom-select copied to clipboard
`selectOnTab` does not set focus to next field
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:
- Create a simple TomSelect and set
selectOnTab
option to true - Click on a select input to open the dropdown
- Select an option by using the up/down keys
- Use the 'TAB' key to select the option
- Result: the dropdown closes and the focus stays on the current input
- 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.
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
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
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