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 with multiple="multiple" triggers a 'change' on every item cleared. #3773
Comments
Same thing is happening in IE11. Also, after invoking the "clear all", the dropdown list appears without adding the select-container--focus class |
Using select2 4.0.3 from CDN. I've created a multi-select via HTML and initialized it via javascript where multiple options are selected. However if I clear one of the selected options they all clear. Is there a fix or work around for this? |
This issue is solved as of 4.0.6-rc.0 (see #5058 (comment)). |
Apologies for commenting on such an old issue but I'm seeing the above behaviour on 4.0.13 (select2.full.js), i.e. multiple change events being fired in response to clearing a multiple select. As this has been marked as resolved I just wanted to clarify whether or not it is considered a bug? In my scenario I'd just like to submit a form on change and would like to keep that logic generic rather than have to worry about whether the event is coming from Select2 or otherwise have to intercept and handle Select2 specific events. $form.on('change', 'select, input', (event) => {...}) Does it deserve a new issue or have I missed something maybe? |
Hello I have the same problems with the latest release. How can we prevent this ? |
I have the same issue with 4.1.0-rc.0 |
If you clear a multiple select with say 5 items. change event will trigger 6 times. 1 for each item cleared and once for finalization. This is on firefox.
The problem is line 1714: this.trigger('unselect', unselectData); apparently unselect triggers the change event.
Possible fixes are comment out this line as it looks useless.
Another fix is to trigger a custom event called unselect-select2 for example to not trigger the change event.
Another fix is to rewrite change event to be called change-select2 and bind that, but this needs to be propogated throughtout the code.
The text was updated successfully, but these errors were encountered: