FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: nested frames order with tabs & suspend/resume (#6528) · NativeScript/NativeScript@7df8038 · GitHub

Commit 7df8038

Browse files
authored
fix: nested frames order with tabs & suspend/resume (#6528)
1 parent 950fdcf commit 7df8038

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

‎tns-core-modules/ui/frame/frame-common.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

‎tns-core-modules/ui/frame/frame.d.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
*/

‎tns-core-modules/ui/tab-view/tab-view.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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 => {

‎tns-core-modules/ui/tab-view/tab-view.ios.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL