Skip to content
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

Transitioning between components fails when component's root node has v-if="false" #6687

Closed
jiangfengming opened this issue Sep 25, 2017 · 4 comments · Fixed by #7023
Closed
Labels

Comments

@jiangfengming
Copy link

Version

2.4.4

Reproduction link

https://jsfiddle.net/by4bfduo/

Steps to reproduce

Click radio "B".

What is expected?

Should switch to component "B".

What is actually happening?

Doesn't switch to "B".


In real scenario, when a user navigates to a new view, I want to load the remote data (in created hook) and set the root node's v-if to true to switch the component in. But when data hasn't been load for some reason, the dynamic component is stuck and can't go anywhere.

@LinusBorg
Copy link
Member

LinusBorg commented Sep 26, 2017

I don't think we currently have defined how <transition> should act if there was no element provided to begin with, so I wouldn't classify this a a bug, but there's certainly room for improvement.

At the very least, the transition should be skipped and the component-b should be rendered.

For now, you can work around this by adding a wrapper div: https://jsfiddle.net/Linusborg/by4bfduo/1/

@jiangfengming
Copy link
Author

But if I wrap a div, the transition won't take effect when data is loaded.

https://jsfiddle.net/80sksyv5/

@posva
Copy link
Member

posva commented Sep 26, 2017

I'm pretty sure we had an error in the past if you tried to use v-if(without v-else) for the root node, (the same as using multiple root nodes)

@jiangfengming
Copy link
Author

I found a very ugly solution: add an empty <div v-else></div>, in every router view component that needs to wait data.

https://jsfiddle.net/vckb4ok5/

@yyx990803 yyx990803 added bug and removed improvement labels Nov 16, 2017
lovelope pushed a commit to lovelope/vue that referenced this issue Feb 1, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants