Skip to content

ability to check push vs replace in navigation guard #1620

@kerlor

Description

@kerlor

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'){
}
}

Activity

zack24q

zack24q commented on Aug 1, 2017

@zack24q

Features are also needed in beforeEach.

deleted a comment from BoltDoggy on Dec 4, 2017
Dadibom

Dadibom commented on Feb 22, 2018

@Dadibom

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

deleted a comment from sneko on Jan 28, 2019
deleted a comment from choegyumin on Mar 13, 2019
deleted a comment from mathk on Mar 18, 2020
deleted a comment from sharitu on Mar 18, 2020
added
needs RFCThis feature request needs to go through the RFC process to gather more information
on Sep 24, 2020
guidobouman

guidobouman commented on Dec 10, 2020

@guidobouman

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestgroup[current route information]Issues regarding current route information that is currently missingneeds RFCThis feature request needs to go through the RFC process to gather more information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @guidobouman@posva@Dadibom@zack24q@kerlor

      Issue actions

        ability to check push vs replace in navigation guard · Issue #1620 · vuejs/vue-router