From 3665b0949e576b644882987e17b4a24de276dc18 Mon Sep 17 00:00:00 2001 From: Anthony Dahlberg Date: Fri, 24 Jul 2026 22:07:59 -0500 Subject: [PATCH] fix(angular): guard transition against destroyed router outlet StackController.destroy() sets containerEl to undefined, but a queued transition can resolve after its ion-router-outlet was destroyed (interrupted, re-entrant, or cancelled navigation). The commit guard dereferenced containerEl unconditionally, throwing "TypeError: undefined is not an object (evaluating 'containerEl.commit')" during normal back-navigation. Null-check containerEl so a transition against a destroyed outlet resolves to false instead of crashing. Co-Authored-By: Claude Fable 5 --- .../common/src/directives/navigation/stack-controller.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/angular/common/src/directives/navigation/stack-controller.ts b/packages/angular/common/src/directives/navigation/stack-controller.ts index 0593219d3f4..e5f89896fd4 100644 --- a/packages/angular/common/src/directives/navigation/stack-controller.ts +++ b/packages/angular/common/src/directives/navigation/stack-controller.ts @@ -275,7 +275,10 @@ export class StackController { enteringEl.classList.add('ion-page'); enteringEl.classList.add('ion-page-invisible'); - if ((containerEl as any).commit) { + // containerEl is set to undefined when the stack controller is destroyed, + // so a transition that resolves after its outlet was destroyed must not + // dereference it (see destroy()). + if ((containerEl as any)?.commit) { return containerEl.commit(enteringEl, leavingEl, { duration: direction === undefined ? 0 : undefined, direction,