-
Notifications
You must be signed in to change notification settings - Fork 1
Only dispatch Select's populated event when appropriate
#232
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
Only dispatch Select's populated event when appropriate
#232
Conversation
This fixes a problem where, when the Select's value is changed (by the user), the `change` and `populated` events are both dispatched, even if the list of options is unchanged. Those subsequent dispatches of the `populated` event make it too easy for consumers of this component to accidentally set the value of the Select back to what it was an instant before, effectively preventing the user's choice from "sticking" sometimes.
| let element = {} | ||
| let mdcSelect = {} | ||
| let previousOptionsIDsCSV = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be passed in, or how are you setting this to previous option IDs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It happens on line 55 inside afterUpdate. The first time options is populated it will be empty, meaning optionsHaveChanged will return true. Is that correct @forevermatt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hobbitronics Yes, that's exactly it.
hobbitronics
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for fixing this.
| let element = {} | ||
| let mdcSelect = {} | ||
| let previousOptionsIDsCSV = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It happens on line 55 inside afterUpdate. The first time options is populated it will be empty, meaning optionsHaveChanged will return true. Is that correct @forevermatt?
|
🎉 This PR is included in version 10.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixed
Selectcomponent dispatchpopulatedevents on initial load or changes to the list of optionschangeandpopulatedevents are both dispatched, even if the list of options is unchanged. Those subsequent dispatches of thepopulatedevent made it too easy for consumers of this component to accidentally set the value of the Select back to what it was an instant before, effectively preventing the user's choice from "sticking" sometimes.