-
Notifications
You must be signed in to change notification settings - Fork 668
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
wrapper.setSelected() triggers a change event even if the option is already selected #1339
Comments
I hesitated to open this as a bug, as the documentation is explicit in saying that However, I believe |
You are correct, it only emits |
@vvanpo as you said and the docs explicitly state it triggers the |
@codebryo I am a bit split here. I agree with you on that one, yet I saw that selecting the same option does not trigger an event... Do we want to emulate a user action or explicitly do what the action states.. hmmmm @afontcu @JessicaSachs Opinions here? |
If I'm not mistaken, vue-test-utils/packages/test-utils/src/wrapper.js Lines 356 to 357 in 950763f
...even though docs say the exact same thing regarding it being an alias of setting the right value and emitting the event. I'd say all |
@afontcu good find, it seems clear to me that emulating user actions is the most intuitive and useful behaviour, here. Interestingly, that same is not true when calling |
If there are no objections, I'll open a PR for this. |
Yes please, @vvanpo |
fix: Ensure setChecked() and setSelected() only trigger DOM events when state is changed (fix #1339)
Version
1.0.0-beta.29
Reproduction link
https://codepen.io/vvanpo/pen/MWWroOK
Steps to reproduce
<select>
element.setSelect()
multiple times on one of the select element's options.<select>
element wrapper'semitted('change').length
is equal to the number of timessetSelect()
was called.What is expected?
A
<select>
element emits achange
event only when the element value has actually changed.What is actually happening?
setSelected()
triggers achange
event every time it is called, regardless of whether the underlying value was changed.The text was updated successfully, but these errors were encountered: