fix: reset swipe and interaction state on pointercancel - #784
Open
solomonaustin wants to merge 1 commit into
Open
fix: reset swipe and interaction state on pointercancel#784solomonaustin wants to merge 1 commit into
solomonaustin wants to merge 1 commit into
Conversation
The browser fires pointercancel instead of pointerup when it takes a pointer over — an OS gesture, another surface stealing the touch, some multi-touch conflicts. Nothing listened for it, so both pieces of state a swipe sets were left behind. On the toast, isSwiping, swipeDirection, the pointer origin and the --swipe-amount-* custom properties stayed as they were, leaving the toast parked mid-swipe until the next full down/up. On the toaster, onPointerDown sets interacting and only onPointerUp clears it. interacting pauses the dismiss timer, so a cancelled gesture left every toast paused and they stopped auto-dismissing. Fixes emilkowalski#779
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.
Fixes #779.
Problem
The browser fires
pointercancelinstead ofpointerupwhen it takes a pointer over — an OS-level gesture, another surface stealing the touch, some multi-touch conflicts. Nothing insrc/index.tsxlistened for it, so both pieces of state a swipe sets were left behind.On the toast,
isSwiping,swipeDirection,pointerStartRefand the--swipe-amount-x/ycustom properties all stayed as they were, leaving the toast parked mid-swipe until the next full down/up cycle. That is the reported bug.On the toaster, there is a second instance of the same gap that the issue does not mention, and it is the worse of the two.
onPointerDownsetsinteracting, and onlyonPointerUpclears it:interactinggates the dismiss timer:So a cancelled gesture left every toast paused and they stopped auto-dismissing entirely, not just visually stuck.
Fix
onPointerCancelin both places. On the toast it unwinds the swipe without dismissing — a cancelled gesture is not a swipe-out. On the toaster it clearsinteractingso the timer resumes.Testing
One Playwright test: swipe part way, fire
pointercancel, assertdata-swipinggoes back tofalseand--swipe-amount-xreturns to0px. It fails onmainand passes with the change.I could not write an honest test for the toaster half, and would rather say so than ship one that looks like coverage. Playwright cannot release its own mouse without emitting
pointerup, andpointerupclearsinteractinganyway — so any test I wrote passed with and without the fix. Going withoutpointerupkeeps pointer capture active, somouseleavenever fires andexpandedstaystrue, which pauses the timer on its own and hides the effect. I confirmed both of those by instrumenting the DOM rather than assuming:Happy to split the toaster change into its own PR if you would rather keep this one to what the test covers.