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
select2:unselect fires before changing value in single-select dropdowns #5049
Comments
Does it even clear the value at all, for single select? See #4845. |
Yes, everything seems to work correctly except for the event which is sent too early. (see the gistrun) As a workaround, the unselect callback can be wrapped in |
Agreed, it should clear the value before triggering the event. Can you please check the issues and open PRs carefully, to see if this has been mentioned before? I'd be quite surprised as this is a pretty obvious bug. |
I have looked at event- and unselect-related issues and haven't found anything similar. I imagine that it could be useful to know what was just unselected, but it would be better to pass it as an event field. |
Please see PR #5058 for a fix. Actually, removed items are already sent as event data, so I have just reversed clearing and event emitting. |
If I understand correctly, the issue here was that |
It's possible. #5058 has already been merged in and released in the 4.0.6-rc.0 pre-release. So, you can try updating to the pre-release and see if that fixes your issue. That would also help us test the pre-release and get it ready for a stable release! |
allowClear
select2:unselect
event$(dropdown).val()
still returns the value in event handlerselect2:unselect
fires, the value is already removed.Expected behavior and actual behavior
This should be consistent for single-selects and multi-selects. Currently for single-selects
select2:unselect
event is fired before removing the value, but for multi-select value is already removed when the event fires.Environment
Browsers
Operating System
Libraries
Isolating the problem
The text was updated successfully, but these errors were encountered: