You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useLongPress listens to both touch and mouse events. After a tap, browsers fire emulated mousedown/mouseup, so one tap is handled as two presses. #576 works around this by ignoring mouse presses within 1 second of a touch, which is a heuristic.
Listening to pointerdown/pointerup/pointercancel instead gives one event stream per press, so the emulated mouse events never reach the hook. pointercancel also cancels the press when the browser starts scrolling, which the hook does not handle today.
This is a breaking change:
The returned handlers become onPointerDown, onPointerUp, onPointerLeave, onPointerCancel (and onPointerMove with moveThreshold).
Callbacks receive PointerEvent instead of MouseEvent | TouchEvent.
Notes:
Track pointerId and ignore non-primary pointers and non-left buttons.
jsdom 25 has no PointerEvent, so tests need a small polyfill (jsdom 27+ ships one).
Activity
hyesungoh commentedon Oct 28, 2026
@rjsgud49 please check this issue 🙏
rjsgud49 commentedon Oct 28, 2026
Thanks for merging #576! I'll pick this up and open a PR soon 🙂