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
maximumSelectionLength is overridden by other configuration options #3514
Comments
Is there a way to work around this bug? |
I'm also having this issue. |
Here is a workaround (depending on your exact needs). Enable closeOnSelect and let the select2 dropdown reopen automatically each time the selection has changed:
` |
@Candyffm not really a perfect solution, because container would flash and options' position may change |
@mayashavin has identified that this is an issue with a few other configuration options as well. From her issue (#4900): Some of the following fields will override
Libraries
Browsers: Google Chrome Investigation: The dataAdapter prototypes get decorated with methods when maximumSelectionLength first, and with tokenSeperators later. Unfortunately, they both have same method name "query", and one will override the other in dataAdapter respectively. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Having same issue fireFox 65 |
Yes. This issue is closed but not fixed. |
Ok I found a workarround for this with little Js on select2. We need to know that maximumSelectionLength is only not allowing user to open the dropdown, it doesn't limit the select inside dropdown if the dropdown kept opened with closeOnSelect. So as a workarround I just added a listener on my select2 and dispatch a close once it attempts the value of limit : I used this two options on my select 2 : And I added a condition on change event, once three elements selected I just dispatch the close on my select2 : Check out this fiddle where I did this update : |
I found a solution that worked for me. #5533 |
until there is a merge of bug fix as @redamakhchan mentioned , his solution works perfectly. I made small mod to even pick the value automatically in solution here, so all you have to do now is configure as usual & copy paste the code here changing the element id.. The solution code below forces the dropdown to close if the user reaches the configured maximumSelectionLength
|
There was a bug where the `maximumSelectionLength` option would not kick in if the `closeOnSelect` option was enabled. Normally, this was enabled by someone in their global configuration, but it could also be seen when somoene selected an option while holding the meta/ctrl/alt keys. This would implicitly enable the `closeOnSelect` behaviour, even when it was not globally enabled, and cause the bug. This fixes that issue by listening to the `select` event which is triggered whenever an option is selected, and triggers the "maximum selected" message based on that event. This should now force the message to be displayed, even when the results did not have to be queried another time. Fixes #3514 Fixes #3860 Closes #5333
* Rewrote maximumSelectionLength tests to use container These brings the tests in line with other tests which we have, and makes it easier to understand what is actually going on in the tests. This also removes a redundant set of tests where we were testing with => 2 options being allowed. There are no current edge cases that would have required this. * Fix maximumSelectionLength being ignored by closeOnSelect There was a bug where the `maximumSelectionLength` option would not kick in if the `closeOnSelect` option was enabled. Normally, this was enabled by someone in their global configuration, but it could also be seen when somoene selected an option while holding the meta/ctrl/alt keys. This would implicitly enable the `closeOnSelect` behaviour, even when it was not globally enabled, and cause the bug. This fixes that issue by listening to the `select` event which is triggered whenever an option is selected, and triggers the "maximum selected" message based on that event. This should now force the message to be displayed, even when the results did not have to be queried another time. Fixes #3514 Fixes #3860 Closes #5333
The property "maximumSelectionLength" does not work when "closeOnSelect" is set to false. I can select more items without any effective limit.
Check out this fiddle where both situations are shown.
http://jsfiddle.net/f9jszen1/
The text was updated successfully, but these errors were encountered: