mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 15:51:16 +08:00
fix(router): navigation guards now fire when navigating to a page with params (#22521)
resolves #22516
This commit is contained in:
@ -33,17 +33,17 @@
|
|||||||
<ion-content class="ion-padding">
|
<ion-content class="ion-padding">
|
||||||
<ion-list>
|
<ion-list>
|
||||||
<ion-button id="router-push">router.push</ion-button><br>
|
<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-button id="router-link">ion-router-link</ion-button><br>
|
||||||
</ion-router-link>
|
</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-list>
|
||||||
</ion-content>`;
|
</ion-content>`;
|
||||||
|
|
||||||
const childButton = this.querySelector('#router-push');
|
const childButton = this.querySelector('#router-push');
|
||||||
childButton.addEventListener('click', () => {
|
childButton.addEventListener('click', () => {
|
||||||
const r = document.querySelector('ion-router');
|
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-redirect from="/" to="/home"></ion-route-redirect>
|
||||||
<ion-route url="/home" component="home-page"></ion-route>
|
<ion-route url="/home" component="home-page"></ion-route>
|
||||||
<ion-route url="/test" component="test-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-router>
|
||||||
|
|
||||||
<ion-nav></ion-nav>
|
<ion-nav></ion-nav>
|
||||||
|
|||||||
@ -13,7 +13,7 @@ test('router: guards - router-link - allow/allow', async () => {
|
|||||||
|
|
||||||
await page.waitForChanges();
|
await page.waitForChanges();
|
||||||
|
|
||||||
await checkUrl(page, '#/child');
|
await checkUrl(page, '#/child/1');
|
||||||
|
|
||||||
const backButton = await page.$('ion-back-button');
|
const backButton = await page.$('ion-back-button');
|
||||||
await backButton.click();
|
await backButton.click();
|
||||||
@ -78,14 +78,14 @@ test('router: guards - router-link - allow/block', async () => {
|
|||||||
|
|
||||||
await page.waitForChanges();
|
await page.waitForChanges();
|
||||||
|
|
||||||
await checkUrl(page, '#/child');
|
await checkUrl(page, '#/child/1');
|
||||||
|
|
||||||
const backButton = await page.$('ion-back-button');
|
const backButton = await page.$('ion-back-button');
|
||||||
await backButton.click();
|
await backButton.click();
|
||||||
|
|
||||||
await page.waitForChanges();
|
await page.waitForChanges();
|
||||||
|
|
||||||
await checkUrl(page, '#/child');
|
await checkUrl(page, '#/child/1');
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO this is an actual bug in the code.
|
// 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 page.waitForChanges();
|
||||||
|
|
||||||
await checkUrl(page, '#/child');
|
await checkUrl(page, '#/child/1');
|
||||||
|
|
||||||
const backButton = await page.$('ion-back-button');
|
const backButton = await page.$('ion-back-button');
|
||||||
await backButton.click();
|
await backButton.click();
|
||||||
|
|||||||
@ -74,7 +74,9 @@ export const matchesPath = (inputPath: string[], chain: RouteChain): RouteChain
|
|||||||
return chain.map((route, i) => ({
|
return chain.map((route, i) => ({
|
||||||
id: route.id,
|
id: route.id,
|
||||||
path: route.path,
|
path: route.path,
|
||||||
params: mergeParams(route.params, allparams![i])
|
params: mergeParams(route.params, allparams![i]),
|
||||||
|
beforeEnter: route.beforeEnter,
|
||||||
|
beforeLeave: route.beforeLeave
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return chain;
|
return chain;
|
||||||
|
|||||||
Reference in New Issue
Block a user