Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/src/components/router/test/guards/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}
}
Expand Down Expand Up @@ -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>
Expand Down
8 changes: 4 additions & 4 deletions core/src/components/router/test/guards/router-link.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand All @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion core/src/components/router/utils/matching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down