-
-
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
closeOnSelect = false does not work when minimumInputLength > 0 #2264
Comments
Works for me (Chrome, Firefox). Which browser are you using? |
This does not work for me in Chrome, Firefox, or IE, but perhaps my understanding of how it is supposed to work is incorrect. When I type 'O', the dropdown appears with all results matching 'O'. When I select an item, I expect the dropdown to remain open since closeOnSelect = false. What happens is, the filter text, 'O', is cleared, and the dropdown closes. This is frustrating to my users, since they want to select multiple items that match the same filter. They need to re-enter the filter text, select the next item, repeat; which can be quite time consuming. For me it is frustrating, because each filter means a request to the database (not seen in the fiddle). So, I need to have at least 1 database call for every item selected. |
I am able to reproduce this, though I'm not entirely sure where the dropdown gets closed. |
It appears to be closing because the entered text is getting cleared at line 2890, regardless of if closeOnSelect is set to false |
I also encountered this bug today in the latest Chrome. |
me too..when I have minimumInputLength set |
I'm having the same issue in both the latest Chrome and IE8: https://github.com/ivaynberg/select2/issues/2512 |
I have the same problem |
…gth is > 1, multiple is true, and closeOnSelect is false
This isn't working for me too. I'm using the latest chrome version. |
Hello, I am experiencing this issue too, it's especially a problem with an ajax-retrieved results. I have found that this is caused by a onSelect method of MultiSelect2 class, specifically by |
Any idea if this will be solved anytime soon? What can we do meanwhile? |
I've fixed this by replacing this : (lines 3003 to 3011)
I've just moved the "clearSearch();" when closeOnSelect is set to true.
Hope it helps anyone. I'm not sure if this breaks something else so I don't have make a pull request. |
This is a blocker for one of our clients. Any ideas on when an official fix will be available? |
Hi. I can confirm the above fix by snichini worked for me... i had the same problem.. i can now have the search term remain even after selecting some options... with the minimum number of search characters set to 2. |
I can also confirm snichini's fix worked for me. |
This does not work in v4.0 beta2. @snichini fix is for v3.5. I did the following hack on lines 3384-3388 in v4, which seems to work: Dropdown.prototype._onSelect = function () {
if (this.options.options.closeOnSelect == false)
return;
this.trigger('close');
}; |
The above fix provided by snichini doesn't work for me (3.5.2). It works for the first item only, when I select the second item the search results get closed. I came up with a different solution that works for me. The idea is not to update search results if they shouldn't be closed on select: // keep track of the search's value before it gets cleared
this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
this.clearSearch();
if (this.select || !this.opts.closeOnSelect) this.postprocessResults(data, false, this.opts.closeOnSelect===true);
if (this.opts.closeOnSelect) {
this.updateResults();
this.close();
this.search.width(10);
} else { ... |
If you do not want to hack the select2 3.5 code then following work ('select2-selecting' event launch before close event so we can manually close/open):
|
@AlexRocks Can you clarify what "uploadSubCats" is doing? Your code itself is not working as this method is missing. |
@AlexRocks Thanks a lot, your code helped me to finish this fix
|
Thank you @spycom |
The issue is related to 3.x version, but the version 3.x is not maintained anymore. But if this bug occurs in 4.x version, please reopen the issue and send us a JSFiddle example code or a PR. |
The dropdown will close on select. I have created a jsfiddle to demonstrate the behavior.
This worked in 3.4.5. I believe (although have not confirmed), that this may have been broken by pull request https://github.com/ivaynberg/select2/pull/1940
The text was updated successfully, but these errors were encountered: