From 9883eac0f74b4ebce6de02d88941cf1ce3efecb3 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 16 Nov 2023 10:52:32 -0500 Subject: [PATCH] fix(angular): transition plays when using browser buttons (#28530) Issue number: resolves #16569 --------- ## What is the current behavior? Ionic Angular's routing integration disables page transitions when using the browser back/forward buttons. ## What is the new behavior? - Transitions now play when using the back/forward buttons ## Does this introduce a breaking change? - [ ] Yes - [x] No We're not aware of any breaking changes here, though it's possible some developers were relying on this behavior. As a result, we are targeting Ionic 8 to minimize any potential negative impact this fix may have on developers. ## Other information Supersedes https://github.com/ionic-team/ionic-framework/pull/28188 Dev build: `7.5.6-dev.11700068172.15ce9b35` Co-authored-by: hoi4 --- packages/angular/common/src/providers/nav-controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular/common/src/providers/nav-controller.ts b/packages/angular/common/src/providers/nav-controller.ts index aff31b090b..1ae3a0a603 100644 --- a/packages/angular/common/src/providers/nav-controller.ts +++ b/packages/angular/common/src/providers/nav-controller.ts @@ -37,9 +37,9 @@ export class NavController { if (router) { router.events.subscribe((ev) => { if (ev instanceof NavigationStart) { + // restoredState is set if the browser back/forward button is used const id = ev.restoredState ? ev.restoredState.navigationId : ev.id; - this.guessDirection = id < this.lastNavId ? 'back' : 'forward'; - this.guessAnimation = !ev.restoredState ? this.guessDirection : undefined; + this.guessDirection = this.guessAnimation = id < this.lastNavId ? 'back' : 'forward'; this.lastNavId = this.guessDirection === 'forward' ? ev.id : id; } });