Allow LogBox and RedBox overlay dismissal via Android back button#56405
Open
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Open
Allow LogBox and RedBox overlay dismissal via Android back button#56405Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary: On Android, pressing the hardware back button while the LogBox inspector is open does nothing. `LogBoxDialog` is explicitly set to `setCancelable(false)` and there's no `onBackPressed()` override, so the back button is completely swallowed. The only way to close the inspector is the on-screen Minimize/Dismiss buttons. For RedBox, the dialog is cancelable by default so back press does dismiss it visually, but it bypasses `hideRedboxDialog()`. The dialog reference and content view don't get cleaned up, leaving stale state. This adds proper back button handling for both: **LogBox**: `LogBoxDialog` now takes an `onRequestClose` callback and overrides `onBackPressed()` to invoke it. The surface delegate passes a callback that emits `hardwareBackPress` to the JS runtime, where a new `BackHandler` listener in `LogBoxInspector` calls `onMinimize()`. This keeps `setCancelable(false)` in place (so tapping outside the dialog doesn't dismiss it) while still running the full dismiss flow through JS: state reset, `NativeLogBox.hide()`, dialog cleanup. **RedBox**: The anonymous `Dialog` subclass now overrides `onBackPressed()` to call `hideRedboxDialog()` directly, which dismisses the dialog, destroys the content view, and nulls the reference. Changelog: [Internal] - Allow LogBox and RedBox overlays to respond to Android back button press Differential Revision: D100081099
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100081099. |
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.
Summary:
On Android, pressing the hardware back button while the LogBox inspector is open does nothing.
LogBoxDialogis explicitly set tosetCancelable(false)and there's noonBackPressed()override, so the back button is completely swallowed. The only way to close the inspector is the on-screen Minimize/Dismiss buttons.For RedBox, the dialog is cancelable by default so back press does dismiss it visually, but it bypasses
hideRedboxDialog(). The dialog reference and content view don't get cleaned up, leaving stale state.This adds proper back button handling for both:
LogBox:
LogBoxDialognow takes anonRequestClosecallback and overridesonBackPressed()to invoke it. The surface delegate passes a callback that emitshardwareBackPressto the JS runtime, where a newBackHandlerlistener inLogBoxInspectorcallsonMinimize(). This keepssetCancelable(false)in place (so tapping outside the dialog doesn't dismiss it) while still running the full dismiss flow through JS: state reset,NativeLogBox.hide(), dialog cleanup.RedBox: The anonymous
Dialogsubclass now overridesonBackPressed()to callhideRedboxDialog()directly, which dismisses the dialog, destroys the content view, and nulls the reference.Changelog: [Internal] - Allow LogBox and RedBox overlays to respond to Android back button press
Differential Revision: D100081099