fix(vue): ensure view is updated correctly when replacing a route outside of a nav guard (#22429)

resolves #22412
This commit is contained in:
Liam DeBeasi
2020-11-04 16:44:51 -05:00
committed by GitHub
parent 9659ad6334
commit 5a4d0c0217
3 changed files with 31 additions and 2 deletions

View File

@ -29,7 +29,15 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) =>
*/
router.afterEach((to: RouteLocationNormalized, _: RouteLocationNormalized) => {
const { direction, action } = currentNavigationInfo;
handleHistoryChange(to, action, direction);
/**
* When calling router.replace, we are not informed
* about the replace action in opts.history.listen
* but we can check to see if the latest routing action
* was a replace action by looking at the history state.
*/
const replaceAction = history.state.replaced ? 'replace' : undefined;
handleHistoryChange(to, action || replaceAction, direction);
currentNavigationInfo = { direction: undefined, action: undefined };
});