Skip to content

Allow LogBox and RedBox overlay dismissal via Android back button#56405

Open
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Abbondanzo:export-D100081099
Open

Allow LogBox and RedBox overlay dismissal via Android back button#56405
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Abbondanzo:export-D100081099

Conversation

@Abbondanzo
Copy link
Copy Markdown
Contributor

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

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
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 9, 2026
@facebook-github-tools facebook-github-tools bot added p: Facebook Partner: Facebook Partner labels Apr 9, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 9, 2026

@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100081099.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant