The back button behavior works for most straightforward cases, but it sometimes replaces the current route when it should actually go back()
to the previous route in the stack.
run ionic serve
- visit root at
localhost:8100
- You should be redirected to /A
- The back button at the top of the page is set to be disabled if the
current_path === history.back
.
- Use the Page buttons to navigate through the following sequence (not limited to this sequence)
- Page B, Page C, Page B, Page A, Page B, Page C
- Press Back Button
- Route Should be /B and back button should be enabled
- Press Back Button
- Route should be /A and back button should be enabled
(
history.state.back !== $route.fullPath
)
- Route is /A and back button is disabled
(
history.state.back === $route.fullPath
)
In some instances router.replace
gets called when router.back
should be called.
// @ionic/vue-router#index.js:221-226
if (routeInfo.lastPathname === routeInfo.pushedByRoute) {
router.back();
}
else {
router.replace({ path: prevInfo.pathname, query: parseQuery(prevInfo.search) });
}
I havent tested yet that this doesn't cause any unexpected issues with nested routes or tabbed routing, but I don't see an obvious reason why it would.
// @ionic/vue-router#index.js:221-226
if (routeInfo.lastPathname === routeInfo.pushedByRoute || prevInfo.pathname === routeInfo.pushedByRoute) {
router.back();
}
else {
router.replace({ path: prevInfo.pathname, query: parseQuery(prevInfo.search) });
}