Skip to content

fix: call onDismiss once per backdrop tap or swipe - #9

Merged
Guiw5 merged 1 commit into
mainfrom
fix/dismiss-once
Oct 11, 2026
Merged

Guiw5 merged 1 commit into
mainfrom
fix/dismiss-once

Conversation

@Guiw5

@Guiw5 Guiw5 commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Cause: handleDrag calls cancel() in the tap and swipe-down dismiss branches. In @use-gesture 10.3.1, DragEngine.cancel() re-runs the handler on a setTimeout(0) with canceled: true and the same tap/movement state, so it reaches the dismiss branch again: one tap or one swipe calls onDismiss twice (consumers that navigate on dismiss go back two entries).

Fix: handleDrag returns early when the gesture state is canceled.

Test: two tests in test/bottom-sheet.test.tsx drive a backdrop tap and a header swipe-down with pointer events and expect exactly one onDismiss call; both failed with 2 calls before the fix.

@Guiw5
Guiw5 merged commit 541b010 into main Oct 11, 2026
2 checks passed
@Guiw5
Guiw5 deleted the fix/dismiss-once branch October 14, 2026 20:27
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.

1 participant