@@ -53,6 +53,24 @@ export class Outlet {
53
53
const lastState = this . peekState ( ) ;
54
54
return lastState && lastState . segmentGroup . toString ( ) === stateUrl ;
55
55
}
56
+
57
+ // Search for frame that can go back.
58
+ // Nested 'primary' outlets could result in Outlet with multiple navigatable frames.
59
+ getFrameToBack ( ) : Frame {
60
+ let frame = this . frames [ this . frames . length - 1 ] ;
61
+
62
+ if ( ! this . isNSEmptyOutlet ) {
63
+ for ( let index = this . frames . length - 1 ; index >= 0 ; index -- ) {
64
+ const currentFrame = this . frames [ index ] ;
65
+ if ( currentFrame . canGoBack ( ) ) {
66
+ frame = currentFrame ;
67
+ break ;
68
+ }
69
+ }
70
+ }
71
+
72
+ return frame ;
73
+ }
56
74
}
57
75
58
76
export interface NavigationOptions {
@@ -251,7 +269,7 @@ export class NSLocationStrategy extends LocationStrategy {
251
269
const topmostFrame = this . frameService . getFrame ( ) ;
252
270
this . currentOutlet = this . getOutletByFrame ( topmostFrame ) ;
253
271
}
254
- this . currentOutlet . frames [ this . currentOutlet . frames . length - 1 ] . goBack ( ) ;
272
+ this . currentOutlet . getFrameToBack ( ) . goBack ( ) ;
255
273
} else {
256
274
// Nested navigation - just pop the state
257
275
if ( isLogEnabled ( ) ) {
@@ -448,6 +466,12 @@ export class NSLocationStrategy extends LocationStrategy {
448
466
if ( currentOutlet . containsFrame ( frame ) && ! isEqualToCurrent ) {
449
467
this . callPopState ( null , true , currentOutlet ) ;
450
468
}
469
+
470
+ if ( ! currentOutlet . isNSEmptyOutlet ) {
471
+ currentOutlet . frames = currentOutlet . frames . filter ( currentFrame => currentFrame !== frame ) ;
472
+ return currentOutlet . frames . length ;
473
+ }
474
+
451
475
return ! currentOutlet . containsFrame ( frame ) ;
452
476
} ) ;
453
477
}
0 commit comments