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

Fix setValue incorrectly assuming there is a change when there is none #26

Merged
merged 1 commit into from
Mar 3, 2016

Conversation

jfremy
Copy link
Contributor

@jfremy jfremy commented Mar 2, 2016

When using the component with multiple set to true and there are no option selected, the setValue call will incorrectly assume there is a change (and trigger a change event) because jquery val method returns null instead of an empty array.
This can trigger an infinite loop if you have a controlled component where the state of the host component is synchronized with the selected elements (hosting component will receive the change, update its state and then send the updated state = [] to the component)

Fix consist in checking if the select is in multiple mode and if so, ensuring we return an empty array in case there is no option selected.

When using the component with multiple set to true and there are no option selected, the setValue call will incorrectly assume there is a change (and trigger a change event) because jquery val method returns null instead of an empty array.
This can trigger an infinite loop if you have a controlled component where the state of the host component is synchronized with the selected elements (hosting component will receive the change, update its state and then send the updated state = [] to the component)

Fix consist in checking if the select is in multiple mode and if so, ensuring we return an empty array in case there is no option selected.
rkit added a commit that referenced this pull request Mar 3, 2016
Fix setValue incorrectly assuming there is a change when there is none
@rkit rkit merged commit 55c8f65 into rkit:master Mar 3, 2016
@rkit
Copy link
Owner

rkit commented Mar 3, 2016

Thanks!

@rkit
Copy link
Owner

rkit commented Mar 3, 2016

I released a new version (0.5.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants