-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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(vModel): fix v-model
being reset in updated
#8639
Conversation
TBR |
I encountered the same problem. How should I bypass this problem now? But in my business, I must bind the click event on the checkbox to modify other values. Is there any way to achieve this? |
Hello, I'm not familiar with your business context. Could you provide the minimal reproducible link, please? |
Hello, my business is more complicated, it is actually similar to the scene in #8638, what can you do? |
Refer here, you can temporarily use asynchronous execution of click events to solve this problem, such as: function onClick() {
setTimeout(() => {
// do something
})
} |
Thank you. According to your tips, I can now use it normally. Thank you for your help. |
checked
gets reset during an updatechecked
and select
gets reset during an update
Size ReportBundles
Usages
|
checked
and select
gets reset during an updatev-model
being reset in updated
CodSpeed Performance ReportMerging #8639 will not alter performanceComparing Summary
|
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
@Alfred-Skyblue 这个 PR 有合并计划吗?因为我启动了新项目,这导致我在很多地方需要在定时器中处理事件。 |
Waiting for review |
I am unable to simulate browser usage scenarios in unit testing, possibly due to issues with event triggering. Therefore, I have not added test cases temporarily. |
I think the one thing this PR is missing is some a test showing it fails before this change and passes after. Just to prevent this issue from happening again in the future. |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
return // store the v-model value on the element so it can be accessed by the | ||
// change listener. |
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.
Prettier has moved this comment, so it's now in the wrong place. I think you'll need to add braces around the if
body to get the comment to stay where it's meant to be.
// store the v-model value on the element so it can be accessed by the | ||
// change listener. | ||
// #8638 | ||
if (value === oldValue) |
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.
Returning early like this won't work if the value
is an Array or Set that's been modified. e.g.:
Running this same example against main
works as expected:
fixed #8638
fixed #8579
If the updated hook of the component is triggered during the triggering of the instruction, the updated hook of the instruction will be triggered and the value of v-model will be reset, resulting in the value of v-model not being updated as expected.