Skip to content

Add BackHandler to dismiss LogBox toasts on back press (#56474)#56474

Closed
Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D101178179
Closed

Add BackHandler to dismiss LogBox toasts on back press (#56474)#56474
Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D101178179

Conversation

@Abbondanzo

@Abbondanzo Abbondanzo commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

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

@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 16, 2026
@meta-codesync

meta-codesync Bot commented Apr 16, 2026

Copy link
Copy Markdown

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

@meta-codesync meta-codesync Bot changed the title Add BackHandler to dismiss LogBox toasts on back press Add BackHandler to dismiss LogBox toasts on back press (#56474) Apr 16, 2026
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
@Abbondanzo Abbondanzo force-pushed the export-D101178179 branch 2 times, most recently from 88c77b3 to c5c236e Compare April 17, 2026 00:16
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request Apr 17, 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
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request Apr 17, 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
Summary:
Pull Request resolved: react#56474

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
@meta-codesync meta-codesync Bot closed this in 6530092 Apr 17, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Apr 17, 2026
@meta-codesync

meta-codesync Bot commented Apr 17, 2026

Copy link
Copy Markdown

This pull request has been merged in 6530092.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @Abbondanzo in 6530092

When will my fix make it into a release? | How to file a pick request?

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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants