fix: nested frames order with tabs & suspend/resume (#6528)

This commit is contained in:
Manol Donev
2018-11-14 10:20:52 +02:00
committed by GitHub
parent 950fdcf5e7
commit 7df8038d09
4 changed files with 36 additions and 3 deletions

View File

@@ -251,6 +251,18 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
}
}
private isNestedWithin(parentFrameCandidate: FrameBase): boolean {
let frameAncestor: FrameBase = this;
while (frameAncestor) {
frameAncestor = <FrameBase>getAncestor(frameAncestor, FrameBase);
if (frameAncestor === parentFrameCandidate) {
return true;
}
}
return false;
}
private raiseCurrentPageNavigatedEvents(isBack: boolean) {
const page = this.currentPage;
if (page) {
@@ -410,6 +422,23 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
return null;
}
public _pushInFrameStackRecursive() {
this._pushInFrameStack();
// make sure nested frames order is kept intact i.e. the nested one should always be on top;
// see https://github.com/NativeScript/nativescript-angular/issues/1596 for more information
const framesToPush = [];
for (const frame of frameStack) {
if (frame.isNestedWithin(this)) {
framesToPush.push(frame);
}
}
for (const frame of framesToPush) {
frame._pushInFrameStack();
}
}
public _pushInFrameStack() {
_pushInFrameStack(this);
}

View File

@@ -158,6 +158,10 @@ export class Frame extends View {
* @private
*/
_pushInFrameStack();
/**
* @private
*/
_pushInFrameStackRecursive();
/**
* @private
*/

View File

@@ -506,7 +506,7 @@ export class TabView extends TabViewBase {
const newItem = items[newIndex];
const selectedView = newItem && newItem.view;
if (selectedView instanceof Frame) {
selectedView._pushInFrameStack();
selectedView._pushInFrameStackRecursive();
}
toLoad.forEach(index => {

View File

@@ -261,7 +261,7 @@ export class TabView extends TabViewBase {
const selectedIndex = this.selectedIndex;
const selectedView = this.items && this.items[selectedIndex] && this.items[selectedIndex].view;
if (selectedView instanceof Frame) {
selectedView._pushInFrameStack();
selectedView._pushInFrameStackRecursive();
}
this._ios.delegate = this._delegate;
@@ -300,7 +300,7 @@ export class TabView extends TabViewBase {
if (newItem && this.isLoaded) {
const selectedView = items[newIndex].view;
if (selectedView instanceof Frame) {
selectedView._pushInFrameStack();
selectedView._pushInFrameStackRecursive();
}
newItem.loadView(newItem.view);