From f2c8db9a0b508caba41ae991ec22aa5abb031291 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 29 Mar 2019 09:40:57 -0400 Subject: [PATCH] fix(angular): account for replaceUrl option (#17879) fixes #15181 --- .../directives/navigation/stack-controller.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/angular/src/directives/navigation/stack-controller.ts b/angular/src/directives/navigation/stack-controller.ts index 331044f47d..638f5f6bb3 100644 --- a/angular/src/directives/navigation/stack-controller.ts +++ b/angular/src/directives/navigation/stack-controller.ts @@ -58,6 +58,25 @@ export class StackController { animation = undefined; } const viewsSnapshot = this.views.slice(); + + const currentNavigation = this.router.getCurrentNavigation(); + /** + * If the navigation action + * sets `replaceUrl: true` + * then we need to make sure + * we remove the last item + * from our views stack + */ + if ( + currentNavigation && + currentNavigation.extras && + currentNavigation.extras.replaceUrl + ) { + if (this.views.length > 0) { + this.views.splice(-1, 1); + } + } + const views = this.insertView(enteringView, direction); return this.wait(async () => { await this.transition(enteringView, leavingView, animation, this.canGoBack(1), false);