fix(vue): router guards are now fired correctly when written in a component (#23821)

resolves #23820
This commit is contained in:
Liam DeBeasi
2021-08-26 10:40:48 -04:00
committed by GitHub
parent 50b88b24c2
commit 3c442228ff
3 changed files with 58 additions and 1 deletions

View File

@ -20,6 +20,14 @@ export const createViewStacks = (router: Router) => {
const registerIonPage = (viewItem: ViewItem, ionPage: HTMLElement) => {
viewItem.ionPageElement = ionPage;
viewItem.ionRoute = true;
/**
* This is needed otherwise Vue Router
* will not consider this component mounted
* and will not run route guards that
* are written in the component.
*/
viewItem.matchedRoute.instances = { default: viewItem.vueComponentRef.value };
}
const findViewItemByRouteInfo = (routeInfo: RouteInfo, outletId?: number, useDeprecatedRouteSetup: boolean = false) => {
@ -202,6 +210,7 @@ export const createViewStacks = (router: Router) => {
viewItem.mount = false;
viewItem.ionPageElement = undefined;
viewItem.ionRoute = false;
viewItem.matchedRoute.instances = {};
}
}