Skip to content

Commit 3c23605

Browse files
committed
fix: location strategy on nested page-router-outlet
1 parent 442ff1e commit 3c23605

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/angular/src/lib/legacy/router/ns-location-strategy.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,11 @@ export class NSLocationStrategy extends LocationStrategy implements OnDestroy {
408408
isEqualToCurrent = currentOutlet.pathByOutlets === this.currentOutlet.pathByOutlets;
409409
}
410410

411-
// Remove outlet from the url tree.
412-
if (currentOutlet.containsFrame(frame) && !isEqualToCurrent) {
411+
// Remove outlet from the url tree, but only when this is its last frame: an outlet
412+
// still showing other frames (e.g. primary after a nested page-router-outlet is
413+
// destroyed) is still routed, and popping it would navigate the app to "/".
414+
const isLastFrame = currentOutlet.containsFrame(frame) && currentOutlet.frames.every((currentFrame) => currentFrame === frame);
415+
if (isLastFrame && !isEqualToCurrent) {
413416
this.callPopState(null, true, currentOutlet);
414417
}
415418

0 commit comments

Comments
 (0)