A way to detect if user has history on current site
AlexXanderGrib opened this issue · comments
What problem is this solving
- A back button. Currently
router.back()
can navigate you to another site
Proposed solution
- Add a boolean property to Router named
canGoBack
or - Make option for
.go()
(.forward()
,.backward()
)router.back({ routeIfLeaving: '/app' })
Describe alternatives you've considered
- Use exposed in
history.state
propertyback
to determine thisasync function navigate() { // This is internal for vue router, there is no other way to detect // is user has previous history on current site // https://github.com/vuejs/router/blob/main/packages/router/src/history/html5.ts#L25 if (history.state.back) { router.back(); } else { await router.push({ path: localePath(props.path) }); } }
A back button. Currently router.back() can navigate you to another site
Side note: I would never come back to your site ever again if it had behaviour like this (if I am understanding you correctly here). It's just not a nice practice.
A back button. Currently router.back() can navigate you to another site
Side note: I would never come back to your site ever again if it had behaviour like this (if I am understanding you correctly here). It's just not a nice practice.
No, you misunderstood, it's more app-like
You can be redirected from help article to /settings/security
And it's more logical that back button redirects you to /settings, rather than to article you came from, especially if app is installed PWA
You can already write to history.state with history.replacestate in a router.aftereach hook to have this feature