fix(android): back press navigates nested frames with history again - #11432
Merged
Merged
Conversation
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.
|
View your CI Pipeline Execution ↗ for commit 0b68fc6
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
Since #11181 (cross-platform NativeWindow), pressing the Android back button in an app whose root
Framehosts a nestedFramewith navigation history exits the app instead of navigating the nested frame back.Both Android back-press handlers in
ui/frame/index.android.tswere changed fromFrame.goBack()toFrame.goBack(view), whereviewis the activity's root view.FrameBase.goBack(frame)only ever looks at the given frame and its ancestors, so handing it the rootFrameskips every nested frame below it. The root frame cannot go back and has no ancestor frames, sogoBackreportsfalse,callSuperbecomestrue, and the activity finishes.Before #11181 the handler let
goBack()default toFrame.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:
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 thatgoBack(topmost(window))navigates the nested frame, and one pins down thatgoBack(rootFrame)does not reach it.Reported by Dimitris Katsampas on Discord.