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

beforeRouteEnter next callback is not called (in this very specific async situation) #2082

Closed
decademoon opened this issue Mar 1, 2018 · 6 comments

Comments

@decademoon
Copy link
Contributor

Version

3.0.1

Reproduction link

http://jsfiddle.net/df4Lnuw6/271/

Steps to reproduce

  • Have a <router-view v-if="ready"> in the root component's template with ready initially false.
  • Have a single route for path / whose component has a beforeRouteEnter hook.
  • Perform the following in the root component's created hook:
    1. Replace the route with /?x=1 (this causes the same component to be reused).
    2. After a timeout, set ready to true.

What is expected?

The callback function passed to next in the beforeRouteEnter hook should be called.

What is actually happening?

The callback function passed to next in the beforeRouteEnter is not called.

@decademoon
Copy link
Contributor Author

A temporary fix is to use history.replaceState directly instead of router.replace.

@posva
Copy link
Member

posva commented Mar 1, 2018

hmm. Since the router-view is not is toggled off with a v-if, there's no component to pass to the next callback. Using a v-show would also let you have the callback.
What do you do in the actual callback that needs to be in the callback?

@decademoon
Copy link
Contributor Author

Since the router-view is not is toggled off with a v-if, there's no component to pass to the next callback.

The issue isn't solely the v-if, if you comment out the router.replace('/?x=1') it will work.

Since this issue requires a very specific setup, I doubt it would affect many people, so it might not be worth fixing, but I thought I'd mention it for what it's worth. Also the workaround works fine for me.

@enomado
Copy link

enomado commented Apr 2, 2018

Not sure should i create new ticket or not... Its about a component beforeRouteEnter guard

I'm using same component for different routes with different meta.content(if its important)
lets say it is category and item

If I initially load page from item, callback for item works
if I initially load from category - it do not works

@jiangshanmeta
Copy link

@enomado

I just found the issue that seems to have the same problem

@posva
Copy link
Member

posva commented Jul 10, 2018

Closingn in favour of #2255 / #2188

@posva posva closed this as completed Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants