Skip to content

Commit f2c8db9

Browse files
authored
fix(angular): account for replaceUrl option (#17879)
fixes #15181
1 parent 346ecb2 commit f2c8db9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

angular/src/directives/navigation/stack-controller.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ export class StackController {
5858
animation = undefined;
5959
}
6060
const viewsSnapshot = this.views.slice();
61+
62+
const currentNavigation = this.router.getCurrentNavigation();
63+
/**
64+
* If the navigation action
65+
* sets `replaceUrl: true`
66+
* then we need to make sure
67+
* we remove the last item
68+
* from our views stack
69+
*/
70+
if (
71+
currentNavigation &&
72+
currentNavigation.extras &&
73+
currentNavigation.extras.replaceUrl
74+
) {
75+
if (this.views.length > 0) {
76+
this.views.splice(-1, 1);
77+
}
78+
}
79+
6180
const views = this.insertView(enteringView, direction);
6281
return this.wait(async () => {
6382
await this.transition(enteringView, leavingView, animation, this.canGoBack(1), false);

0 commit comments

Comments
 (0)