-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
defineModel
doesn't run if the same value is selected
#11541
Comments
This seems to be as expected, because when the selected state is clicked again, the value of modelValue does not change, so the set method is not triggered. |
This way you can achieve your needs: |
But this feels like a breaking change, because this worked in Vue 3.4.16, and was broken in a patch update between 3.4.16 and 3.4.36. It originally worked as I expected it to work, and now has broken many instances in my application because of this change. |
related PR |
But surely how it used work was consistent with how If you select the same value via a writeable computed property it runs the set function regardless. The defineModel should really work the same way. |
I opened a PR to solve this problem, which contains some of my own opinions. @edison1105 Do you have time to take a look? thank you🫰 |
Vue version
3.4.36
Link to minimal reproduction
https://shorturl.at/I2MOA
Steps to reproduce
Select an option on the button to select, and then click the same option to deselect.
Expected:
The option should de-select.
Actual:
Nothing
What is expected?
When selecting the same option twice, it should select the option then deselect the option.
What is actually happening?
When selecting the same option twice, the original click selects the option but the second click doesn't do anything.
System Info
Any additional comments?
This worked previously on an older version of Vue:
3.4.16
. Yesterday (6th August 2024) I ramnpm install
and it updated a patch version of Vue (3.4.36
).After that my button component stopped working correctly. I feel like this is a breaking change.
The text was updated successfully, but these errors were encountered: