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

ability to check push vs replace in navigation guard #1620

Open
kerlor opened this issue Jul 19, 2017 · 3 comments · May be fixed by #1906 or #3653
Open

ability to check push vs replace in navigation guard #1620

kerlor opened this issue Jul 19, 2017 · 3 comments · May be fixed by #1906 or #3653
Labels
feature request group[current route information] Issues regarding current route information that is currently missing needs RFC This feature request needs to go through the RFC process to gather more information
Projects

Comments

@kerlor
Copy link

kerlor commented Jul 19, 2017

What problem does this feature solve?

I am trying to create a single page mobile app with a push/pop/modal navigation. This navigation behavior is similar to the iOS SDK's navigation controller behavior.
To get this to work in my code I have added a new field(navigationType: push | pop | modal) in the params object. Then in router.afterEach I check for this new field.

It would be nice to have this be part of the vue router api. Considering the push/replace is already separate API.

What does the proposed API look like?

usage might be:
router.afterEach((to, from) => {
if(to.navigationType == 'push'){
} else if(to.navigationType == 'replace'){
}
}

@zack24q
Copy link

zack24q commented Aug 1, 2017

Features are also needed in beforeEach.

@Dadibom
Copy link

Dadibom commented Feb 22, 2018

As many +1's as I can give.
I need this in scrollBehavior

@vuejs vuejs deleted a comment from sneko Jan 28, 2019
@vuejs vuejs deleted a comment from choegyumin Mar 13, 2019
@posva posva added this to Design proposals + discussion (high prio, high complex) in Longterm Mar 26, 2019
@posva posva added the group[current route information] Issues regarding current route information that is currently missing label Mar 26, 2019
@vuejs vuejs deleted a comment from mathk Mar 18, 2020
@vuejs vuejs deleted a comment from sharitu Mar 18, 2020
@posva posva added the needs RFC This feature request needs to go through the RFC process to gather more information label Sep 24, 2020
@guidobouman
Copy link

guidobouman commented Dec 10, 2020

When you have a navigation guard that needs to stick on a part on the URL, no matter if it's a push or replace, this becomes very hard to do transparently.

If we follow @posva's suggestion, suddenly all locations that use a replace also need to pass on another navigation prop, to indicate that this was a replace to the navigation guards. This seems to be the only way for our navigation guard next(to) call to be a push or replace based on the initial navigation that triggered the guard.

iceprosurface added a commit to iceprosurface/vue-router that referenced this issue Oct 26, 2021
iceprosurface added a commit to iceprosurface/vue-router that referenced this issue Oct 26, 2021
iceprosurface added a commit to iceprosurface/vue-router that referenced this issue Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request group[current route information] Issues regarding current route information that is currently missing needs RFC This feature request needs to go through the RFC process to gather more information
Projects
Longterm
Design proposals + discussion (high p...
5 participants