Skip to content

Support 2 extra parameters when navigating like with router.push #2332

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

Closed
xMartin opened this issue Aug 2, 2018 · 8 comments
Closed

Support 2 extra parameters when navigating like with router.push #2332

xMartin opened this issue Aug 2, 2018 · 8 comments

Comments

@xMartin
Copy link

xMartin commented Aug 2, 2018

Version

3.0.1

Reproduction link

https://codepen.io/xMartin/pen/EpLPKr

Steps to reproduce

  1. Open browser console
  2. Click on link "Go to Bar"
  3. Click on link "Go to Baz (redirect to bar in beforeResolve handler)"

What is expected?

See "after /bar" as the last entry in the console.

What is actually happening?

See "redirect to /bar" as the last entry in the console.


All works fine if the current route is not the one that is going to be redirected to in beforeResolve. It also works fine if the redirect happens in beforeEach.

@posva
Copy link
Member

posva commented Aug 2, 2018

This is expected as the redirect makes is cancelling the navigation

@posva posva closed this as completed Aug 2, 2018
@xMartin
Copy link
Author

xMartin commented Aug 2, 2018

Thanks for the feedback!

My use-case is showing a loading bar when routing starts and hiding it when routing is done. I'm using beforeEach and afterEach so far but for this special case the loading bar is never hidden.

Any idea how this can be accomplished?

@xMartin
Copy link
Author

xMartin commented Aug 7, 2018

@posva I understand this behavior is expected but then vue-router might be missing a feature to support my use-case described above.

@posva
Copy link
Member

posva commented Aug 7, 2018

Maybe we could support 2 extra parameters like with router.push, for onComplete and onAbort. Or maybe it's time for global onAbort too

@posva posva reopened this Aug 7, 2018
@posva posva changed the title afterEach not triggered when redirecting in beforeResolve Support 2 extra parameters when navigating like with router.push Aug 7, 2018
@xMartin
Copy link
Author

xMartin commented Aug 7, 2018

A global onAbort makes sense to me.

This edge case of redirecting to the current route is a tough one, because it is not really an explicit abort. As a developer I might expect the same thing (callback and all) to happen as any other route transition.

Anyway, a global onAbort would fix my issue :)

@xMartin

This comment has been minimized.

@posva
Copy link
Member

posva commented Aug 7, 2018

I appreciate your interest but it's not really necessary to add more to this thread 🙂

@vuejs vuejs deleted a comment from diaevd Aug 7, 2018
@posva
Copy link
Member

posva commented Mar 26, 2019

Closing in favour of #2012

For the moment, the loading bar can be cancelled by using the router.onError

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

No branches or pull requests

2 participants