Skip to content

fix(android): back press navigates nested frames with history again - #11432

Merged
NathanWalker merged 1 commit into
mainfrom
fix/android-back-press-nested-frames
Sep 14, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/android-back-press-nested-frames

Conversation

@edusperoni

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Since #11181 (cross-platform NativeWindow), pressing the Android back button in an app whose root Frame hosts a nested Frame with navigation history exits the app instead of navigating the nested frame back.

Both Android back-press handlers in ui/frame/index.android.ts were changed from Frame.goBack() to Frame.goBack(view), where view is the activity's root view. FrameBase.goBack(frame) only ever looks at the given frame and its ancestors, so handing it the root Frame skips every nested frame below it. The root frame cannot go back and has no ancestor frames, so goBack reports false, callSuper becomes true, and the activity finishes.

Before #11181 the handler let goBack() default to Frame.topmost(), which is the frame highest in the frame stack - the nested frame that last navigated - so its history was popped correctly.

What is the new behavior?

The back-press handlers now scope to the window instead of the root view:

callSuper = view instanceof Frame ? !Frame.goBack(Frame.topmost(nativeWindow)) : true;

Frame.topmost(window) (added in #11181 for exactly this purpose) returns the frame highest in the stack that belongs to the activity's window, so a nested frame with history is found again. This keeps the multi-window guarantee the original change was after - back press never navigates a frame that lives in another activity's window - while restoring the single-window behaviour from before the regression, since there the window-scoped topmost frame is the global topmost frame.

Two regression specs are added to frame-common.spec.ts: one shows that goBack(topmost(window)) navigates the nested frame, and one pins down that goBack(rootFrame) does not reach it.

Reported by Dimitris Katsampas on Discord.

Scope the activity's back press to the topmost frame of its window instead of
handing the root view to Frame.goBack(). goBack(frame) only walks up to
ancestors, so passing the root frame skipped nested frames that still had
history and finished the activity.
@nx-cloud

nx-cloud Bot commented Sep 14, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 0b68fc6

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 49s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-14 18:08:02 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11432
npm i https://pkg.pr.new/@nativescript/vite@11432
npm i https://pkg.pr.new/@nativescript/webpack@11432

commit: 0b68fc6

@CatchABus CatchABus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@NathanWalker
NathanWalker merged commit 77fdddd into main Sep 14, 2026
9 of 10 checks passed
@NathanWalker
NathanWalker deleted the fix/android-back-press-nested-frames branch September 14, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants