Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for highlightFirstItem to always highlight first actual result #6280

Open
b-nik opened this issue Oct 17, 2023 · 0 comments
Open

Option for highlightFirstItem to always highlight first actual result #6280

b-nik opened this issue Oct 17, 2023 · 0 comments

Comments

@b-nik
Copy link

b-nik commented Oct 17, 2023

I think it might be useful to have an option so that highlightFirstItem won't highlight the first selected item, but will always highlight the first actual result instead.

The usecase I think it can be useful for is this:
When typing to search in the select2 field, the first result is often the most relevant one - and can easily be selected by pressing the enter key immediately after typing.
However, if I've already selected something before, and it happens to also be returned by the search, it will be highlighted, and then either the mouse of the arrow keys must be used to select the first result which is most often what i wanted after typing.
So an option to control this behavior could be useful.

( Relevant code: https://github.com/select2/select2/blob/master/src/js/select2/results.js#L100 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant