Skip to content

Commit b782e36

Browse files
authored
fix: look for correct outlet to back to (#58)
1 parent 855452c commit b782e36

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Outlet {
5151
isNSEmptyOutlet: boolean;
5252

5353
// Used in reuse-strategy by its children to determine if they should be detached too.
54-
shouldDetach: boolean = true;
54+
shouldDetach = true;
5555
constructor(outletKey: string, path: string, pathByOutlets: string, modalNavigationDepth?: number) {
5656
this.outletKeys = [outletKey];
5757
this.isPageNavigationBack = false;

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,17 @@ export class PageRouterOutlet implements OnDestroy {
327327
// Add it to the new page
328328
this.viewUtil.appendChild(page, componentView);
329329

330-
const topActivatedRoute = findTopActivatedRouteNodeForOutlet(this._activatedRoute.snapshot);
331-
const outletKey = this.locationStrategy.getRouteFullPath(topActivatedRoute);
330+
let topActivatedRoute = findTopActivatedRouteNodeForOutlet(this._activatedRoute.snapshot);
331+
let outletKey = this.locationStrategy.getRouteFullPath(topActivatedRoute);
332+
const thisRouteKey = outletKey;
333+
while (!this.locationStrategy.findOutlet(outletKey)) {
334+
topActivatedRoute = topActivatedRoute.parent;
335+
if (!topActivatedRoute) {
336+
NativeScriptDebug.routerError('Could not find outlet for route: ' + thisRouteKey);
337+
break;
338+
}
339+
outletKey = this.locationStrategy.getRouteFullPath(topActivatedRoute);
340+
}
332341

333342
const navigatedFromCallback = (<any>global).Zone.current.wrap((args: NavigatedData) => {
334343
if (args.isBackNavigation) {

0 commit comments

Comments
 (0)