Skip to content

fix: respect swipeDirections for fast flick dismissals - #773

Open
q121212 wants to merge 1 commit into
emilkowalski:mainfrom
q121212:fix/swipe-respect-swipeDirections-on-flick
Open

fix: respect swipeDirections for fast flick dismissals#773
q121212 wants to merge 1 commit into
emilkowalski:mainfrom
q121212:fix/swipe-respect-swipeDirections-on-flick

Conversation

@q121212

@q121212 q121212 commented Jul 11, 2026

Copy link
Copy Markdown

Fixes #762

Problem

When swipeDirections excludes a direction (e.g. ['top', 'right'] — no left), a fast flick leftward still dismisses the toast.

Root Cause

onPointerMove correctly dampens disallowed swipes (caps at ~15–20px), but a 100ms flick at 15px produces velocity ≈ 0.15, which exceeds the 0.11 threshold in onPointerUp. The velocity check had no awareness of swipeDirections.

Fix

In onPointerUp, compute the intended swipe direction from the sign of the displacement, then check it against swipeDirections before allowing dismissal. This mirrors the intent already enforced in onPointerMove for slower swipes.

The onPointerUp handler dismissed toasts based on velocity alone,
without checking if the swipe direction was actually allowed in
swipeDirections. A fast flick in a disallowed direction still
produced enough velocity (> 0.11) to trigger dismissal because
onPointerMove dampened but didn't zero-out disallowed movement.

Fix: check swipeDirections before dismissing, matching the intent
already enforced in onPointerMove for slow swipes.

Fixes emilkowalski#762
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sonner Error Error Jul 11, 2026 2:32pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fast flick dismisses toast in directions excluded from swipeDirections

1 participant