Skip to content

fix: Adjust router.go to fire navigation guards #3252

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
wants to merge 1 commit into from

Conversation

sirlancelot
Copy link
Contributor

@sirlancelot sirlancelot commented Jul 7, 2020

Adjust router.go to fire navigation guards when using abstract routing mode.

Close #3250

@@ -167,6 +167,7 @@ beforeRouteLeave (to, from, next) {
7. Call `beforeRouteEnter` in activated components.
8. Call global `beforeResolve` guards.
9. Navigation confirmed.
1. Call global `onReady` hooks (Only during initial navigation).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact numbering is not required in markdown. Normally to make a numbered list I would just make everything 1. in order to avoid the delta showing all subsequent items in the list as changed. If the team is okay with that, I'll update the numbering accordingly.

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I don't think it's a good idea calling it inside the runQueue function. I think we should be consistent with how it was before #2292 and call it where updateRoute was called but after ensureURL

No need to update the documentation for this one.

We would also need a test. This one should work as a unit test

@sirlancelot
Copy link
Contributor Author

Thanks for the feedback @posva. I'll work on the requested the changes and add a unit test tonight (PDT).

@posva
Copy link
Member

posva commented Aug 3, 2020

@sirlancelot Hello! Let me know if you still want to work on this or if you don't mind me taking it

@sirlancelot sirlancelot force-pushed the aftereach-hook-call branch from 3bb9985 to 8d30f32 Compare August 4, 2020 06:50
@sirlancelot
Copy link
Contributor Author

Hi @posva, apologies for the radio silence. I've actually discovered that the real issue has to do with abstract mode's router.go() logic. Other routing modes basically call out to transitionTo rather than confirmTransition. I'll update the pull request accordingly. I haven't made a unit test for it yet as I couldn't really find a good spot where this kind of behavior would be tested.

@sirlancelot sirlancelot changed the title fix: call afterHooks later (#3250) fix: Adjust router.go to fire navigation guards Aug 4, 2020
@posva
Copy link
Member

posva commented Aug 4, 2020

No worries at all! As you a unit test, since this is only about abstract mode, you can create a new file that instantiates the router in abstract mode, setup an after each, trigger a navigation and check it works.

@posva
Copy link
Member

posva commented Sep 24, 2020

Fixed in 4da7021

@posva posva closed this Sep 24, 2020
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

Successfully merging this pull request may close these issues.

Abstract history mode doesn't fire afterEach hooks when using router.go()
2 participants