File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -251,6 +251,18 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
251251 }
252252 }
253253
254+ private isNestedWithin ( parentFrameCandidate : FrameBase ) : boolean {
255+ let frameAncestor : FrameBase = this ;
256+ while ( frameAncestor ) {
257+ frameAncestor = < FrameBase > getAncestor ( frameAncestor , FrameBase ) ;
258+ if ( frameAncestor === parentFrameCandidate ) {
259+ return true ;
260+ }
261+ }
262+
263+ return false ;
264+ }
265+
254266 private raiseCurrentPageNavigatedEvents ( isBack : boolean ) {
255267 const page = this . currentPage ;
256268 if ( page ) {
@@ -410,6 +422,23 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
410422 return null ;
411423 }
412424
425+ public _pushInFrameStackRecursive ( ) {
426+ this . _pushInFrameStack ( ) ;
427+
428+ // make sure nested frames order is kept intact i.e. the nested one should always be on top;
429+ // see https://github.com/NativeScript/nativescript-angular/issues/1596 for more information
430+ const framesToPush = [ ] ;
431+ for ( const frame of frameStack ) {
432+ if ( frame . isNestedWithin ( this ) ) {
433+ framesToPush . push ( frame ) ;
434+ }
435+ }
436+
437+ for ( const frame of framesToPush ) {
438+ frame . _pushInFrameStack ( ) ;
439+ }
440+ }
441+
413442 public _pushInFrameStack ( ) {
414443 _pushInFrameStack ( this ) ;
415444 }
Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ export class Frame extends View {
158158 * @private
159159 */
160160 _pushInFrameStack ( ) ;
161+ /**
162+ * @private
163+ */
164+ _pushInFrameStackRecursive ( ) ;
161165 /**
162166 * @private
163167 */
Original file line number Diff line number Diff line change @@ -506,7 +506,7 @@ export class TabView extends TabViewBase {
506506 const newItem = items [ newIndex ] ;
507507 const selectedView = newItem && newItem . view ;
508508 if ( selectedView instanceof Frame ) {
509- selectedView . _pushInFrameStack ( ) ;
509+ selectedView . _pushInFrameStackRecursive ( ) ;
510510 }
511511
512512 toLoad . forEach ( index => {
Original file line number Diff line number Diff line change @@ -261,7 +261,7 @@ export class TabView extends TabViewBase {
261261 const selectedIndex = this . selectedIndex ;
262262 const selectedView = this . items && this . items [ selectedIndex ] && this . items [ selectedIndex ] . view ;
263263 if ( selectedView instanceof Frame ) {
264- selectedView . _pushInFrameStack ( ) ;
264+ selectedView . _pushInFrameStackRecursive ( ) ;
265265 }
266266
267267 this . _ios . delegate = this . _delegate ;
@@ -300,7 +300,7 @@ export class TabView extends TabViewBase {
300300 if ( newItem && this . isLoaded ) {
301301 const selectedView = items [ newIndex ] . view ;
302302 if ( selectedView instanceof Frame ) {
303- selectedView . _pushInFrameStack ( ) ;
303+ selectedView . _pushInFrameStackRecursive ( ) ;
304304 }
305305
306306 newItem . loadView ( newItem . view ) ;
You can’t perform that action at this time.
0 commit comments