Add BackHandler to dismiss LogBox toasts on back press (#56474)#56474
Open
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Open
Add BackHandler to dismiss LogBox toasts on back press (#56474)#56474Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Abbondanzo wants to merge 1 commit intofacebook:mainfrom
Conversation
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D101178179. |
Abbondanzo
added a commit
to Abbondanzo/react-native
that referenced
this pull request
Apr 16, 2026
Summary: On Android, pressing the hardware back button while LogBox notification toasts or the full inspector overlay are visible has no effect on the JS side. The only way to dismiss notifications is the on-screen X button, and the only way to close the inspector is via Minimize/Dismiss. This adds `BackHandler` listeners to both JS containers: **Notification toasts**: A new `LogBoxNotificationBackHandler` component mounts alongside the toasts and registers a `hardwareBackPress` listener that calls `clearWarnings()` + `clearErrors()`, equivalent to pressing X on every visible toast. The component returns null and auto-cleans the listener on unmount. **Inspector overlay**: `LogBoxInspectorContainer` registers a `hardwareBackPress` listener in `componentDidMount` that calls `_handleMinimize()` (`setSelectedLog(-1)`), closing the overlay non-destructively — same as pressing the Minimize button. Changelog: [Android][Added] - Allow LogBox notification toasts and inspector overlay to be dismissed via Android back button Differential Revision: D101178179
b9fceb1 to
88c77b3
Compare
Summary: On Android, pressing the hardware back button while LogBox notification toasts or the full inspector overlay are visible has no effect on the JS side. The only way to dismiss notifications is the on-screen X button, and the only way to close the inspector is via Minimize/Dismiss. This adds `BackHandler` listeners to both JS containers: **Notification toasts**: A new `LogBoxNotificationBackHandler` component mounts alongside the toasts and registers a `hardwareBackPress` listener that calls `clearWarnings()` + `clearErrors()`, equivalent to pressing X on every visible toast. The component returns null and auto-cleans the listener on unmount. **Inspector overlay**: `LogBoxInspectorContainer` registers a `hardwareBackPress` listener in `componentDidMount` that calls `_handleMinimize()` (`setSelectedLog(-1)`), closing the overlay non-destructively — same as pressing the Minimize button. Changelog: [Android][Added] - Allow LogBox notification toasts and inspector overlay to be dismissed via Android back button Differential Revision: D101178179
88c77b3 to
c5c236e
Compare
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 LogBox notification toasts or the full inspector overlay are visible has no effect on the JS side. The only way to dismiss notifications is the on-screen X button, and the only way to close the inspector is via Minimize/Dismiss.
This adds
BackHandlerlisteners to both JS containers:Notification toasts: A new
LogBoxNotificationBackHandlercomponent mounts alongside the toasts and registers ahardwareBackPresslistener that callsclearWarnings()+clearErrors(), equivalent to pressing X on every visible toast. The component returns null and auto-cleans the listener on unmount.Inspector overlay:
LogBoxInspectorContainerregisters ahardwareBackPresslistener incomponentDidMountthat calls_handleMinimize()(setSelectedLog(-1)), closing the overlay non-destructively — same as pressing the Minimize button.Changelog: [Android][Added] - Allow LogBox notification toasts and inspector overlay to be dismissed via Android back button
Differential Revision: D101178179