fix(ui): prevent duplicate long press timers (#1192)

* fix(ui): prevent duplicate long press timers

* fix(ui): clear long press on touch cancel

---------

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-12 11:07:40 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent b94afbc6ef
commit f4ec7d6c1b
+3 -1
View File
@@ -26,6 +26,7 @@ export function useLongPress({
}, []);
const onPointerDown = useCallback((e: React.PointerEvent | React.TouchEvent) => {
clear();
isLongPressRef.current = false;
// Store start position to detect movement
@@ -44,7 +45,7 @@ export function useLongPress({
}
onLongPress();
}, delay);
}, [delay, onLongPress, enableHaptic]);
}, [clear, delay, onLongPress, enableHaptic]);
const onPointerMove = useCallback((e: React.PointerEvent | React.TouchEvent) => {
if (!startPosRef.current || !timerRef.current) return;
@@ -95,6 +96,7 @@ export function useLongPress({
onTouchStart: onPointerDown, // Add touch handlers for better mobile support
onTouchMove: onPointerMove,
onTouchEnd: onPointerUp,
onTouchCancel: clear,
onContextMenu,
};
}