-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Parent navigation guard inconsistently re-run when redirecting between child routes #2224
Comments
Relevant docs explaining expected functionality: https://router.vuejs.org/guide/advanced/navigation-guards.html#Per-Route-Guard |
per the repro, seems to be isolated to when the redirect chain starts on initial "load". Notice it does not happen if the redirect chain is started from the router-link. Only the hard nav version |
Since you are redirecting while entering on the first time, it has to trigger again each time you redirect. This is the correct behavior. After the first navigation to one of the children, it doesn’t re enter the parent so it doesn’t trigger again. |
how is this the correct behavior? we are not re-entering the parent. We are entering a separate child |
See below for clarifications on the weird behavior |
If that is the correct behavior, then this series of events shouldn't be possible, correct?
This is also reproducible randomly at the repro I shared. |
Following a router link to any of the "redirected to" examples does not trigger the parent before enter so this is an inconsistency with the handling of a router-link vs a redirect when going between siblings. I think at least the docs should be updated to clarify how these situations are handled differently if this is in fact the desired behavior |
Reproduction
https://codesandbox.io/p/sandbox/vue-3-router-forked-ns47pv
Steps to reproduce the bug
On the homepage, click the link labeled "start the redirects (hard nav)"
Observe the console
After clicking this 3-4 times you will get the beforeEnter for home logged in-between a child redirect. eg
Expected behavior
Parent beforeEnter would only ever run once when changing between child routes. Eg logs matching
Actual behavior
Parent beforeEnter is re-run in an inconsistent/hard to predict manner.
Additional information
Initially found on vue-router v4.0.12 but was able to repro on latest per sandbox.
The text was updated successfully, but these errors were encountered: