fix(router): navigation guards now fire when navigating to a page with params (#22521)

resolves #22516
This commit is contained in:
Liam DeBeasi
2020-11-18 14:36:49 -05:00
committed by GitHub
parent 3ed44993e1
commit 1956f98968
3 changed files with 11 additions and 9 deletions

View File

@ -33,17 +33,17 @@
<ion-content class="ion-padding">
<ion-list>
<ion-button id="router-push">router.push</ion-button><br>
<ion-router-link href="/child">
<ion-router-link href="/child/1">
<ion-button id="router-link">ion-router-link</ion-button><br>
</ion-router-link>
<ion-button href="/child" id="href">href</ion-button>
<ion-button href="/child/1" id="href">href</ion-button>
</ion-list>
</ion-content>`;
const childButton = this.querySelector('#router-push');
childButton.addEventListener('click', () => {
const r = document.querySelector('ion-router');
r.push('/child');
r.push('/child/1');
});
}
}
@ -145,7 +145,7 @@
<ion-route-redirect from="/" to="/home"></ion-route-redirect>
<ion-route url="/home" component="home-page"></ion-route>
<ion-route url="/test" component="test-page"></ion-route>
<ion-route url="/child" component="child-page"></ion-route>
<ion-route url="/child/:id" component="child-page"></ion-route>
</ion-router>
<ion-nav></ion-nav>

View File

@ -13,7 +13,7 @@ test('router: guards - router-link - allow/allow', async () => {
await page.waitForChanges();
await checkUrl(page, '#/child');
await checkUrl(page, '#/child/1');
const backButton = await page.$('ion-back-button');
await backButton.click();
@ -78,14 +78,14 @@ test('router: guards - router-link - allow/block', async () => {
await page.waitForChanges();
await checkUrl(page, '#/child');
await checkUrl(page, '#/child/1');
const backButton = await page.$('ion-back-button');
await backButton.click();
await page.waitForChanges();
await checkUrl(page, '#/child');
await checkUrl(page, '#/child/1');
});
// TODO this is an actual bug in the code.
@ -102,7 +102,7 @@ test('router: guards - router-link - allow/redirect', async () => {
await page.waitForChanges();
await checkUrl(page, '#/child');
await checkUrl(page, '#/child/1');
const backButton = await page.$('ion-back-button');
await backButton.click();

View File

@ -74,7 +74,9 @@ export const matchesPath = (inputPath: string[], chain: RouteChain): RouteChain
return chain.map((route, i) => ({
id: route.id,
path: route.path,
params: mergeParams(route.params, allparams![i])
params: mergeParams(route.params, allparams![i]),
beforeEnter: route.beforeEnter,
beforeLeave: route.beforeLeave
}));
}
return chain;