From 237c3c2e2d93eba30aee4576b939468cb386c8f5 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 24 Aug 2026 16:59:50 -0400 Subject: [PATCH] fix: Ignore small movements on useSwipe hook (#13549) --- app/hooks/useSwipe.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/hooks/useSwipe.tsx b/app/hooks/useSwipe.tsx index c95d5d6af9..5c2b5b089a 100644 --- a/app/hooks/useSwipe.tsx +++ b/app/hooks/useSwipe.tsx @@ -1,6 +1,9 @@ import { isNumber } from "es-toolkit/compat"; import { useRef } from "react"; +/** Minimum distance in pixels that a touch must travel to count as a swipe. */ +const MinSwipeDistance = 40; + type Props = { onSwipeRight: () => void; onSwipeLeft: () => void; @@ -47,6 +50,12 @@ export default function useSwipe({ const dx = touchXEnd.current - touchXStart.current; const dy = touchYEnd.current - touchYStart.current; + // Ignore small movements so that a tap, or the start of a gesture, is not + // mistaken for a swipe. + if (Math.max(Math.abs(dx), Math.abs(dy)) < MinSwipeDistance) { + return; + } + const swipeRight = dx > 0 && Math.abs(dy) < Math.abs(dx); if (swipeRight) { resetTouchPoints();