fix(vue): correctly switch tabs after going back (#22309)

resolves #22307
This commit is contained in:
Liam DeBeasi
2020-11-04 12:50:31 -05:00
committed by GitHub
parent a9b2260100
commit daf6a92127
6 changed files with 188 additions and 27 deletions

View File

@ -234,15 +234,33 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
const [pathname] = path.split('?');
if (routeInfo) {
incomingRouteParams = Object.assign(Object.assign({}, routeInfo), { routerAction: 'push', routerDirection: 'none' });
const search = (routeInfo.search) ? `?${routeInfo.search}` : '';
router.push(routeInfo.pathname + search);
incomingRouteParams = {
...incomingRouteParams,
routerAction: 'push',
routerDirection: 'none',
tab
}
/**
* When going back to a tab
* you just left, it's possible
* for the route info to be incorrect
* as the tab you want is not the
* tab you are on.
*/
if (routeInfo.pathname === pathname) {
router.push(routeInfo.pathname + search);
} else {
router.push(pathname + search);
}
}
else {
handleNavigate(pathname, 'push', 'none', undefined, tab);
}
}
const handleSetCurrentTab = (tab: string) => {
currentTab = tab;