chosen
chosen copied to clipboard
Tab should populate with currently displayed option
When a dropdown item is highlighted, "tab" should populate the select with that option. This seems like a very natural feature that appears missing.
It doesn't appear hard to customize chosen with this behavior, but it would be much nicer built-in.
- http://stackoverflow.com/questions/27726434/how-can-i-select-an-option-in-the-chosen-js-multiple-dropdown-with-the-tab-key
- http://stackoverflow.com/questions/15668221/jquery-chosen-populate-multiple-select-with-tab-button
I can submit a pull request, but I first wanted to see if there was a reason someone hadn't already done this (at least as an option defaulted to false)? I looked through closed issues too and didn't see any discussion on this topic.
It should, per https://github.com/harvesthq/chosen/pull/265
Are you using the most recent release? If not, does upgrading fix your problem?
If still not, what browser, browser version, OS, and OS version are you using?
Closing for now until more info is provided, but we'll reopen if you can provide an update.
I am testing on the latest release and can confirm, when searching via typing, then arrowing, then tabbing away from the item - the item is not "selected". The user must hit
Test Case: http://harvesthq.github.io/chosen/index.html Browsers tested and don't select items when tabbing away from the items are:
- FireFox 41
- Edge
- Chrome (whatever the latest is)
- IE11 on Windows 10 (version: 11.0.10240.16431)
@seanmcne All of those on Windows?
Thanks for the quick response! Yes, those are all on Windows, I've tested on Windows 10 and Windows 8.1.
I see that the single select works as requested, but multiple select doesn't.
And I assume it's intentional, because if tab would select a result, then there would be no way of passing by the select without selecting anything.
And I assume it's intentional, because if tab would select a result, then there would be no way of passing by the select without selecting anything.
This seems like the TAB behaviour is inconsistent from multiple select to single select. On the demo site, 1.8.7:
- single select and TAB works by selecting the current search result, closing results and focusing the select again
- multiple select and TAB works by deselecting the current search result and focusing the next input field.
On my view having different behaviours is a bug. Personally I would prefer to change the multiple select to have the same behaviour as single as it seems to be the 'right' behaviour. If we want to get fancy, we can have an option to select if TAB should deselect and go to next input or select the option and stay focus on the current input.
In my project, I just changed this line -- not great, I know, but the solution would be to change these lines: https://github.com/harvesthq/chosen/blob/be0a298f528ec59ce97889eaeeeb47a2dca9ca79/coffee/lib/abstract-chosen.coffee#L254-L257
to:
when 9 # tab
if @results_showing && (!@is_multiple || @options.multiselect_allow_tab_to_select)
this.result_select(evt)
@mouse_on_container = false
break
Depending on whether a default option should be preserved, there may need to be some work in set_default_values
Thought this might help someone actually get a PR going on a 4-year-old issue.