Closed miljan-aleksic closed 8 years ago
@miljan-aleksic FYI, I implemented support for this but decided to revert it. The point is that <transition>
should be wrapping the direct node that is being manipulated by v-show
or v-if
. When you use v-show
or v-if
inside the component, it becomes indirect and imo ends up being harder to reason about.
So there are two options for the use case:
<transition>
and v-show
in the parent scope.<transition>
and v-show
inside the child component. In this case you can also allow the user to pass in props to customize the transition.I was playing around with the changes and it introduced some new bugs difficult to confirm, plus during the process I had the chance to experiment more with the different configurations. Keeping the transitions direct gives you full power over the overall process which in more complex components could be necessary.
I totally agree with your decision and thanks for letting me know, @yyx990803.
I am not sure if it's the best way to go, but I thought that leaving the transition wrapper outside the components would leave more freedom to integrate it as required (for example with or without keep-alive, custom events callbacks, etc).
With that in mind and taking as example a modal component it would usually have a show prop used to control the modal display. Transition expects v-show to know when to start and to avoid this kind of code
<modal v-show="show" :show="show" />
the v-show would be set in the component root directly. The final code with transition would be simple asBut that would not work as transition expects v-show right there. There is a jsfiddle that illustrate the issue (just ignore the badly implemented transition css...).
I see two ways to solve this:
Vue.js version
2.0.0-rc1
Reproduction Link
https://jsfiddle.net/miljan/8Lca03gb/
Steps to reproduce
Try opening the modal
What is Expected?
To open with a transition, which does happen if you set v-show again in the component declaration.
What is actually happening?
It opens without a transition.