-
-
Couldn't load subscription status.
- Fork 8.9k
Description
Vue version
3.4.35
Link to minimal reproduction
Steps to reproduce
Click on "Toggle show test component"
What is expected?
The component opens with padding set to 100 initially.
What is actually happening?
The padding is animated from 0 to 100.
System Info
No response
Any additional comments?
This happens because when the component is initially mounted, the v-bind variables aren't set yet. So if onMounted triggers a DOM layout recalculation, then the padding is set to 0, after which it is immediately set to 100, triggering the animation. This didn't happen in older versions (for example 3.4.21).
But there is a similar, probably related issue that happens 3.4.35 and in older versions like 3.4.21: in some cases (I was able to reproduce it using Teleport), mounted in directives can be executed after the component already exists in the DOM but before the v-bind variables are set. If mounted then triggers a DOM layout recalculation, the same animation issue can happen again. Here's the code to reproduce it.
Basically, it would make things a lot easier if there was a guarantee that the element isn't added to the dom before the v-bind values are set to their initial values.