[2.6] DOM isn't sync with the data
See original GitHub issueVersion
2.6.6
Reproduction link
2.6.6 https://jsfiddle.net/6gn53fzj/ 2.5.22 https://jsfiddle.net/3mp518t7/
Steps to reproduce
- Click on test button
What is expected?
Only “a” checkbox to be checked.
What is actually happening?
Please take a look at the test
method. In this function I simultaneously trigger click on two checkboxes, after which I wait for the DOM to be patched and finally I update checked
array with the value ['a']
. I expect at this point that only checkbox a
is checked, but that’s not the case here. For some reason inputs c
and d
also stays checked. Even if I wait some extra time after nextTick or enforce component’s update before changing checked
value, it does not help. I undestend this issue is related to reverting nextTick to use Microtask but still can’t figure out why this happens and what workaround can I apply to fix it. Appreciate your help. Thanks 😃
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top GitHub Comments
@sqal good to know.
To summarize: the reason why you have to
await this.$nextTick()
after each click is to give Vue the opportunity to sync the state changes triggered by a click to all the sibling checkboxes.I’m afraid this will have to be a wontifx because:
@yyx990803 In my case, yes, you’re right. After upgrading Vue to 2.6.6 I saw bunch of my unit tests where I manually trigger UI event started to fail. Here’s an example of a test with a fix I had to add (suggested by posva):
otherwise it fails in this line:
I guess I will have to adjust my other tests the same way… Thank you for detailed response though 😃 And yeah… I haven’t ran into similar problem outside of unit tests.