From 328d9acc48a2ef0c5bd19c94e22c9ec7ef3ae112 Mon Sep 17 00:00:00 2001 From: William Sedlacek Date: Thu, 7 Oct 2021 15:09:39 -0700 Subject: [PATCH 1/2] fix: skip ChildrenOutLetContexts destroy hook if outlet has been changed --- .../src/lib/legacy/router/page-router-outlet.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/angular/src/lib/legacy/router/page-router-outlet.ts b/packages/angular/src/lib/legacy/router/page-router-outlet.ts index a690d57..a250f6b 100644 --- a/packages/angular/src/lib/legacy/router/page-router-outlet.ts +++ b/packages/angular/src/lib/legacy/router/page-router-outlet.ts @@ -148,9 +148,14 @@ export class PageRouterOutlet implements OnDestroy { } ngOnDestroy(): void { - // Clear accumulated modal view page cache when page-router-outlet - // destroyed on modal view closing - this.parentContexts.onChildOutletDestroyed(this.name); + // In the event that the `parentContexts` has changed the outlet + // via the creation of another outlet, the `onChildOutletDestroyed` + // will be skipped + if (this.parentContexts.getContext(this.name).outlet === this) { + // Clear accumulated modal view page cache when page-router-outlet + // destroyed on modal view closing + this.parentContexts.onChildOutletDestroyed(this.name); + } if (this.outlet) { this.outlet.outletKeys.forEach((key) => { From f68a5c6f5ef5d614f5e30904ac976563272dc69e Mon Sep 17 00:00:00 2001 From: wSedlacek Date: Fri, 17 Dec 2021 00:15:21 -0800 Subject: [PATCH 2/2] fix: handle case where `getContext()` is null --- packages/angular/src/lib/legacy/router/page-router-outlet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular/src/lib/legacy/router/page-router-outlet.ts b/packages/angular/src/lib/legacy/router/page-router-outlet.ts index a250f6b..94e675e 100644 --- a/packages/angular/src/lib/legacy/router/page-router-outlet.ts +++ b/packages/angular/src/lib/legacy/router/page-router-outlet.ts @@ -151,7 +151,7 @@ export class PageRouterOutlet implements OnDestroy { // In the event that the `parentContexts` has changed the outlet // via the creation of another outlet, the `onChildOutletDestroyed` // will be skipped - if (this.parentContexts.getContext(this.name).outlet === this) { + if (this.parentContexts.getContext(this.name)?.outlet === this) { // Clear accumulated modal view page cache when page-router-outlet // destroyed on modal view closing this.parentContexts.onChildOutletDestroyed(this.name);