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

Limiting the number of selections does not work using CTRL #3860

Closed
FredericoSFerreira opened this issue Oct 22, 2015 · 6 comments · Fixed by #5581
Closed

Limiting the number of selections does not work using CTRL #3860

FredericoSFerreira opened this issue Oct 22, 2015 · 6 comments · Fixed by #5581

Comments

@FredericoSFerreira
Copy link

The maximum number of selection does not work when you use the CTRL key to perform the multiple selection

@alexyorke
Copy link
Contributor

👍

What browser/OS have you tested this bug with? Since this is an older bug, does the newest version of select (4.0.1-rc.1 at the time of this writing) work?

@kevin-brown
Copy link
Member

You can reproduce this in 4.0.1-rc.1 by looking at the examples page.

https://select2.github.io/examples.html#multiple-max

This is because the maximum selection limit is enforced whenever the dropdown is opened, instead of when the selection is made.

@urkle
Copy link

urkle commented Mar 5, 2018

This issue still happens in the latest 4.x release (new URL to page showing the issue https://select2.org/selections#limiting-the-number-of-selections )

@stale
Copy link

stale bot commented Mar 13, 2019

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.

@stale stale bot added the status: stale label Mar 13, 2019
@urkle
Copy link

urkle commented Mar 19, 2019

This is still occurring in the latest code.

@stale stale bot removed the status: stale label Mar 19, 2019
@kevin-brown
Copy link
Member

This is a duplicate of #3514.

kevin-brown added a commit that referenced this issue Jul 21, 2019
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
kevin-brown added a commit that referenced this issue Jul 21, 2019
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants