Select component with search (like Select2)
See original GitHub issueIs your feature request related to a problem? Please describe…
If the option list for <select>
elements (i.e. <b-form-select :options="options" />
) becomes long, users cannot easily find what they want to select. This is especially true if the option list is sorted by value, and not by label text (e.g. with localized labels, but that’s easy to overcome).
This is a shortcoming of the Browser’s UI capabilities, providing no search for <select>
elements. Once opened, the user can start typing, and the option list is matched (but only with a prefix match). This only works reliably on desktop browsers.
There’s also a <datalist>
element, which allows searching/matching, but last time I checked, it didn’t behave like a dropdown list and allowed entering custom values.
Describe the solution you’d like
I’d like to have either an option to <b-form-select>
, or a separate component which implements something like Select2, Chosen or Vue Select:
An input field for the user to search options + a dropdown list with matching options.
If no match is found, a short message indicating this fact should displayed instead of the dropdown list. Allowing new values should not be possible (or at least be disabled by default).
Describe alternatives you’ve considered
- Typeahead, Select2, Chosen require jQuery
- Vue Select requires extra work to make it look like the rest of the application (no Bootstrap styling)
- Vue Selectize mostly does what I want, but brings redundant features (sth. similar to
<b-form-tags>
), thus increasing the bundle size; it also has no Bootstrap styling <datalist>
allows entering new values, and needs custom styling (adding aclass="form-control"
might do the trick)<b-form-input>
combined with<b-dropdown>
this is my current approach. It requires a bit CSS hackery to properly position the dropdown list and a larger chunk of JS code to open/close/filter the list.
Additional context
Vue Selectize, Example “Single Item Select” |
---|
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5
Top GitHub Comments
Adding some Starter Code for anyone willing to hack away. This works but the only difference is it uses HTML input and not b-form-input.
Addendum
I’ve found these issues (after creating this one, of course 🙄) which mention a search/filter functionality.
It looks like, this feature is on the way. Is there a way to beta-test it?