Key increment in combination with await makes a component jump out of its parent HTML node. Is it a bug? #12772
Unanswered
progmars
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have encountered a weird issue in my app when a component unexpectedly jumps out of its parent HTML node.
I have a bit of a messy model requiring full component refresh sometimes and I've seen a few people recommending
:key
increment approach as a quick & dirty workaround for full refresh. Everything worked fine in general. Then I happened to increment the key twice in my flow, separated by anawait
, and the component did something strange - it jumped to another place in my app!I managed to reduce it to a minimal use case available here: https://playcode.io/2232962
When you click the button, the key will be incremented and
await
will be executed, and then you will notice that the red rectangle has jumped out of its former parent green rectangle.If you remove the
await
before thedoIt
call or if you remove one of the increments, or if the setup of the JumpTest component does not do its own innerawait
, it works just fine and you can click the button many times with no jumping.I will clean up my flow of execution to avoid having
await
between key increments. The second increment definitely should not be needed. Still, I'm puzzled and curious about the reasons behind this behavior.If someone wants to try it locally, here's the relevant code:
App.vue:
JumpTest.vue:
index.html:
package.json:
script.js:
Beta Was this translation helpful? Give feedback.
All reactions