Skip to content

Commit 47f4c25

Browse files
authored
fix(frame): push recreated frame back in frameStack when Don't Keep Activities enabled (#8096)
1 parent 786aca3 commit 47f4c25

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎nativescript-core/ui/frame/frame-common.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,31 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
7070
const top = FrameBase.topmost();
7171
if (top && top.canGoBack()) {
7272
top.goBack();
73-
73+
7474
return true;
7575
} else if (top) {
7676
let parentFrameCanGoBack = false;
7777
let parentFrame = <FrameBase>getAncestor(top, "Frame");
78-
78+
7979
while (parentFrame && !parentFrameCanGoBack) {
8080
if (parentFrame && parentFrame.canGoBack()) {
8181
parentFrameCanGoBack = true;
8282
} else {
8383
parentFrame = <FrameBase>getAncestor(parentFrame, "Frame");
8484
}
8585
}
86-
86+
8787
if (parentFrame && parentFrameCanGoBack) {
8888
parentFrame.goBack();
89-
89+
9090
return true;
9191
}
9292
}
93-
93+
9494
if (frameStack.length > 1) {
9595
top._popFromFrameStack();
9696
}
97-
97+
9898
return false;
9999
}
100100

@@ -216,11 +216,11 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
216216
traceWrite(`NAVIGATE`, traceCategories.Navigation);
217217
}
218218

219+
this._pushInFrameStack();
220+
219221
const entry = buildEntryFromArgs(param);
220222
const page = Builder.createViewFromEntry(entry) as Page;
221223

222-
this._pushInFrameStack();
223-
224224
const backstackEntry: BackstackEntry = {
225225
entry: entry,
226226
resolvedPage: page,

‎nativescript-core/ui/frame/frame.android.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,13 @@ export class Frame extends FrameBase {
483483
}
484484

485485
public createNativeView() {
486+
// Create native view with available _currentEntry occur in Don't Keep Activities
487+
// scenario when Activity is recreated on app suspend/resume. Push frame back in frame stack
488+
// since it was removed in disposeNativeView() method.
489+
if (this._currentEntry) {
490+
this._pushInFrameStack();
491+
}
492+
486493
return new org.nativescript.widgets.ContentLayout(this._context);
487494
}
488495

0 commit comments

Comments
 (0)