Skip to content

Commit c68ecb8

Browse files
author
William Sedlacek
authored
fix: skip ChildrenOutLetContexts destroy hook if outlet has been changed (#38)
1 parent 3923237 commit c68ecb8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/angular/src/lib/legacy/router/page-router-outlet.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,14 @@ export class PageRouterOutlet implements OnDestroy {
148148
}
149149

150150
ngOnDestroy(): void {
151-
// Clear accumulated modal view page cache when page-router-outlet
152-
// destroyed on modal view closing
153-
this.parentContexts.onChildOutletDestroyed(this.name);
151+
// In the event that the `parentContexts` has changed the outlet
152+
// via the creation of another outlet, the `onChildOutletDestroyed`
153+
// will be skipped
154+
if (this.parentContexts.getContext(this.name)?.outlet === <any>this) {
155+
// Clear accumulated modal view page cache when page-router-outlet
156+
// destroyed on modal view closing
157+
this.parentContexts.onChildOutletDestroyed(this.name);
158+
}
154159

155160
if (this.outlet) {
156161
this.outlet.outletKeys.forEach((key) => {

0 commit comments

Comments
 (0)