Skip to content

Commit 16f1c52

Browse files
Merge branch 'master' into myankov/action-bar-visibility
2 parents 7e18895 + 854a120 commit 16f1c52

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Diff for: nativescript-angular/router/ns-location-strategy.ts

+15-14
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,21 @@ export class NSLocationStrategy extends LocationStrategy {
126126
this.currentUrlTree = urlSerializer.parse(url);
127127
const urlTreeRoot = this.currentUrlTree.root;
128128

129+
// Handle case where the user declares a component at path "/".
130+
// The url serializer doesn't parse this url as having a primary outlet.
129131
if (!Object.keys(urlTreeRoot.children).length) {
130-
// Handle case where the user declares a component at path "/".
131-
// The url serializer doesn't parse this url as having a primary outlet.
132-
const rootOutlet = this.createOutlet("primary", null, null);
133-
this.currentOutlet = rootOutlet;
132+
const segmentGroup = this.currentUrlTree && this.currentUrlTree.root;
133+
const outletKey = this.getSegmentGroupFullPath(segmentGroup) + "primary";
134+
const outlet = this.findOutletByKey(outletKey);
135+
136+
if (outlet && this.updateStates(outlet, segmentGroup)) {
137+
this.currentOutlet = outlet; // If states updated
138+
} else if (!outlet) {
139+
const rootOutlet = this.createOutlet("primary", segmentGroup, null);
140+
this.currentOutlet = rootOutlet;
141+
}
142+
143+
this.currentOutlet.peekState().isRootSegmentGroup = true;
134144
return;
135145
}
136146

@@ -543,21 +553,12 @@ export class NSLocationStrategy extends LocationStrategy {
543553
}
544554

545555
private createOutlet(outletKey: string, segmentGroup: any, parent: Outlet, modalNavigation?: number): Outlet {
546-
let isRootSegmentGroup: boolean = false;
547-
548-
if (!segmentGroup) {
549-
// Handle case where the user declares a component at path "/".
550-
// The url serializer doesn't parse this url as having a primary outlet.
551-
segmentGroup = this.currentUrlTree && this.currentUrlTree.root;
552-
isRootSegmentGroup = true;
553-
}
554-
555556
const pathByOutlets = this.getPathByOutlets(segmentGroup);
556557
const newOutlet = new Outlet(outletKey, pathByOutlets, modalNavigation);
557558

558559
const locationState: LocationState = {
559560
segmentGroup: segmentGroup,
560-
isRootSegmentGroup: isRootSegmentGroup,
561+
isRootSegmentGroup: false,
561562
isPageNavigation: true // It is a new OutletNode.
562563
};
563564

Diff for: tests/app/tests/ns-location-strategy.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class FakeFrame extends View implements Frame {
2727
actionBarVisibility: "always" | "auto" | "never";
2828
transition: any;
2929
_currentEntry: any;
30+
_executingEntry: any;
3031

3132
canGoBack(): boolean {
3233
return true;

0 commit comments

Comments
 (0)