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

Detect popstate vs push/replace in navigation guards #3453

Open
posva opened this issue Jan 23, 2021 · 4 comments
Open

Detect popstate vs push/replace in navigation guards #3453

posva opened this issue Jan 23, 2021 · 4 comments
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

Comments

@posva
Copy link
Member

posva commented Jan 23, 2021

It would be useful to detect if navigation comes from interaction within the app (router.push()) or outside of it (history.back()).

The API is still to be decided and should be the same on v4 and v3, probably something inside of the to parameter of navigation guards

router.beforeEach((to, from, next) => {
  to.navigation.type // 'pop' | 'push'
  to.replace // true | false
  to.navigation.direction // number

Related #1620

@posva posva added 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 labels Jan 23, 2021
@KaelWD
Copy link

KaelWD commented May 22, 2022

I'd also like to be able to tell the difference between router.back() vs the browser back button being pressed.

@antlionguard

This comment was marked as spam.

@rezaffm
Copy link

rezaffm commented Apr 13, 2023

Any update?

@posva
Copy link
Member Author

posva commented Apr 13, 2023

this and any other current route information will have to wait for https://github.com/WICG/navigation-api to become stable in terms of API so we can provide an API that aligns with it (namely using transient information) and avoid breaking changes as much as possible. Locking until then

@vuejs vuejs locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
None yet
Development

No branches or pull requests

4 participants