-
-
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
allowClear conflicts with selectOnClose #4475
Comments
I think just not opening when the x is clicked should take care of it, easier said than done though |
Removing line 65: this.trigger('toggle', {}); of allowClear.js fixes the issue. If it's being cleared, it should go away, not open |
Can you expand upon the issue you are facing by adding a few more pieces of information to your bug report?
The contributing guide contains a useful section with a few questions which can help us track down the bug and speed up the process of finding a fix for it. The creation of an isolated test case would also be useful. |
I'm using Select2 4.0.3, ubuntu 16.04, chrome |
I have a temp fix with this:
Basically clears it a second time after it was cleared but reselected the first time |
+1 for a fix to this issue please... I use IMHO the clear button should not toggle the select2 menu, as in it should be 'clear-able' with the menu open or closed. |
As far as I can see... and more generally... it's impossible to submit an empty selection if
|
@gravelld exactly |
Actually, looks like the remove icons are covered here: #3209 (comment) |
Is there any fix for this issue? |
This is a very common scenario, is it gonna be fixed? |
@phazei I am trying your temporary fix, but i am not sure I understand.. |
Nope, $selection and $element are internal things to s2, they come with the object which is defined like so:
|
I like to solve Problems like this using the options attributes, so I figured this out: But IMO it is strange that this issue isn't fixed yet, this is a common scenario in my applications too. There should be an option to disable opening the menu on clearing, as this is frequently requested and most workarounds will collide with selectOnClose. Alternatively, you should disable selectOnClose if there is no input. |
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. |
This is still an issue in the latest 4.1.0-rc.0 With options.selectOnClose = true and options.allowClear = true it clears the selection the when you click the X but then selects whatever option is active in the list. |
Create select with a couple options and enable the options allowClear and selectOnClose
When the "x" is clicked on the clear, the select box opens with first item highlighted. Close box, and now it's selected.
Basically, there's no way to clear if selectOnClose is on...
The text was updated successfully, but these errors were encountered: