GithubHelp home page GithubHelp logo

Comments (8)

pm0u avatar pm0u commented on June 16, 2024

Relevant docs explaining expected functionality: https://router.vuejs.org/guide/advanced/navigation-guards.html#Per-Route-Guard

from router.

pm0u avatar pm0u commented on June 16, 2024

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

from router.

posva avatar posva commented on June 16, 2024

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.

from router.

pm0u avatar pm0u commented on June 16, 2024

how is this the correct behavior? we are not re-entering the parent. We are entering a separate child

from router.

pm0u avatar pm0u commented on June 16, 2024

Also, it doesn't always happen on the first redirect. Sometimes it happens on the 2nd or third which would not be "while entering."

Additionally, sometimes it doesn't happen at all. It also doesn't happen when the redirects are preceded by a router navigation. Is this difference expected?

See below for clarifications on the weird behavior

from router.

pm0u avatar pm0u commented on June 16, 2024

@posva

If that is the correct behavior, then this series of events shouldn't be possible, correct?

home beforeEnter
child1 beforeEnter
child2 beforeEnter
child3 beforeEnter
child4 beforeEnter

This is also reproducible randomly at the repro I shared.

from router.

pm0u avatar pm0u commented on June 16, 2024

Seems to perhaps be an issue with the sandbox env. Opening in a new window, the logs I get are:

home beforeEnter
child1 beforeEnter
home beforeEnter
child2 beforeEnter
home beforeEnter
child3 beforeEnter
home beforeEnter
child4 beforeEnter

So, seems the inconsistency at least is due to the environment. But regardless, is this confirmed to be expected behavior that the parent nav guard would trigger before every single redirect?

If it is, then is it possible to accomplish a redirect from child to child without re-running the parent beforeEnter? If not, I think the docs should be updated as they seem to suggest that this would not be how the navigation guards would be handled.

image

from router.

pm0u avatar pm0u commented on June 16, 2024

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

from router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.