fix: toast stacking issue on mobile after closing a notification (#1268) #1270
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.
solution2.mp4
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.