fix: reset interacting state on pointercancel - #775
Open
ngtpro wants to merge 1 commit into
Open
Conversation
The browser fires pointercancel instead of pointerup when it takes over the gesture (touch scrolling, pull-to-refresh, long-press selection, app switch). Since interacting was only cleared in onPointerUp, it stayed true forever in that case. interacting gates the auto-close timer and lives on the Toaster rather than an individual toast, so a single cancelled gesture stopped every toast on the page from auto-dismissing for the rest of its lifetime. Adds an onPointerCancel handler and a regression test.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ngtpro
marked this pull request as ready for review
July 27, 2026 17:18
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.
Problem
The
<ol>inToastersetsinteractingon pointer down and only clears it on pointer up:There is no
onPointerCancel. When the browser takes over a gesture it firespointercancelinstead ofpointerup— thepointerupevent never arrives — sointeractingstaystrue.interactinggates the auto-close timer:…and it lives on the
Toaster, not on an individual toast. So one cancelled gesture stops every toast on the page from auto-dismissing for the rest of the page's lifetime — not just the one that was touched. To the user, toasts simply pile up and never go away.Common
pointercanceltriggers on mobile:We hit this in production on mobile and had to work around it by force-dismissing toasts from the app side.
Fix
Reset the same state on cancel:
Test
Adds
toast is removed when the pointer gesture is cancelledtotest/tests/basic.spec.ts, which dispatchespointerdownfollowed bypointercanceland asserts the toast still auto-dismisses.Verified locally against chromium:
expect(toast).toHaveCount(0)gets1, the toast never dismissesFull suite: 36 passed, 1 failed. The one failure is
cancel button dismisses the custom toast with empty id, which fails on the base commit too and is unrelated (it looks like the same thing #724 is addressing).Notes
onPointerLeavemay be worth considering separately, for the case where the pointer leaves the element while still down. I left it out to keep this focused.