react-toastify icon indicating copy to clipboard operation
react-toastify copied to clipboard

fix: toast stacking issue on mobile after closing a notification (#1268)

Open sins051301 opened this issue 1 month ago • 0 comments

https://github.com/user-attachments/assets/90cc5710-949f-4f51-be87-80e517d5b07c

What

Restores stacked toast behavior on mobile by ensuring the toast group expands again when the user taps outside the toast container. On desktop, existing hover behavior remains unchanged.

Why

On mobile devices, stacked toasts could not be expanded again after being collapsed. This happened because mobile browsers do not trigger focus/blur or mouseenter/mouseleave events reliably. As a result, the logic that re-expanded the toast stack on outside interaction never fired. This PR introduces a mobile-friendly interaction model to fix that.

How

Added a pointerdown-based outside click handler to detect taps outside the toast container on mobile. When a pointerdown occurs outside the container, the toast stack is expanded again. The change applies only to mobile/touch behavior and does not affect desktop hover interactions. Removed reliance on focus-based logic for mobile platforms. This ensures the stack collapses and re-expands correctly across both desktop and mobile environments.

Testing

Tested on Chrome mobile emulator (iOS & Android). Tested on physical Android device.

Confirmed:

Tapping outside the toast on mobile re-expands the stacked toasts. Desktop behavior (hover expand/collapse) remains unchanged. No regressions in existing autoClose or hover pause features.

sins051301 avatar Nov 23 '25 13:11 sins051301