-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
disable search on select boxes with multiple selection #4797
Comments
My current workaround is this:
|
+1 |
1 similar comment
+1 |
Also hitting this. Would really like to have the search option disabled for multiselects with finite options. My work-around (not very elegant): setTimeout(function() { |
@chlorophyllkid your solution seems to work well, so I am adding it to the documentation. |
Now documented here: https://select2.org/searching#multi-select |
I somehow couldn't get the proposed solution to work. However, this one works for me every time:
|
Is it possible to completely disable user input. I still can type in the select box. I want to disable it. |
For those who might wind up here from a google search like I did: I used this and it works even on a refresh. Note that I haven't tested with sending values to the server because it's only for an in-page filter (and that works so no reason sending to server wouldn't, mentioning just in case).
|
This documented solution works only from the second click on iPad. On the first click before the input is disabled, the iPad keyboard occurs already. Are there any events that can be used before the first click? |
I guess at this point workarounds should not be the proper solution to this problem anymore. |
Alguien me puede ayudar con mi problema? sucede que mi Muchas gracias de ante mano |
Whilst I'm using the documented workaround on this, there are a few other gotchas I'm wrestling with...
As mentioned, a proper option for search disable would be ideal - I'm using it for a user-defined set of options that will only ever be about a dozen, so typing not required. However, any ideas on fixing the above would be handy. I've tried disabling on load to fix 1, but doesn't work. |
The other workarounds did not work to totally disable the search on multi-select. But an option 'disableSearch: true' would be a nice addition so we don't have to kludge around this. |
adding the inputmode part solved the ipad/iphone first click issue for me |
The mentioned fix in the documentation doesn't properly work on mobile. For the first click on mobile, it opens the keyboard anyway. Below should fix it compltely: inputElement.parent().find('.select2-search__field').on('focus', () => {
inputElement.parent().find('.select2-search__field').prop('disabled', true);
}); where |
Thank you. My bad! I deleted the comment. |
What if I want to display the search box when I select multiple options |
I tried to get to work the following configuration:
I did not find a good solution. Disabling the search field introduces a new problem: the disabled search field is still present and does not receive clicks anymore - so it is hard or even impossible to close the drop down again. I use a current Firefox (Version 122, 2024-02-09). Are there any suggestions? PS: voted for an official option instead of any kind of workaround |
I ran into a problem using this approach that the dropdown was only shown if I clicked on a parent span element that contained a disabled search field (I suspect that the disabled property disabled the event listener responsible for it), so using the 'readonly' property instead of 'disabled' worked very well for me.
(where 'el' is the select actual element) |
Hi everyone,
as the title indicates I'm looking for a possibility to disable the search on selects with multiple selection.
I already know there is:
minimumResultsForSearch: Infinity
And it works fine on selects with single selection, but doesn't seem to have any effect on select boxes with multiple selection.
Oh, and I'm currently using select2 4.0.3..
Here is a fiddle http://jsfiddle.net/jEADR/3608/
thanks in advance :)
The text was updated successfully, but these errors were encountered: