From fefab4fc3bb9231db35b9cf2ae7b5f79f76fc757 Mon Sep 17 00:00:00 2001 From: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com> Date: Tue, 3 Nov 2026 04:00:46 +0530 Subject: [PATCH] fix: ignore touch taps with out-of-order timestamps --- resources/js/lib/reactions.ts | 1 + tests/Unit/Reactions.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/resources/js/lib/reactions.ts b/resources/js/lib/reactions.ts index 3b4022221..34f48fc16 100644 --- a/resources/js/lib/reactions.ts +++ b/resources/js/lib/reactions.ts @@ -122,6 +122,7 @@ const doubleTapDistance = 24; export function isDoubleTap(previous: Tap | null, tap: Tap): boolean { return ( previous !== null && + tap.time >= previous.time && tap.time - previous.time <= doubleTapWithin && Math.hypot(tap.x - previous.x, tap.y - previous.y) <= doubleTapDistance ); diff --git a/tests/Unit/Reactions.test.ts b/tests/Unit/Reactions.test.ts index 534244197..6bc45fe5a 100644 --- a/tests/Unit/Reactions.test.ts +++ b/tests/Unit/Reactions.test.ts @@ -101,4 +101,5 @@ await test('takes two quick taps close together as a double tap', () => { assert.equal(isDoubleTap(first, { x: 100, y: 200, time: 1_400 }), false); assert.equal(isDoubleTap(first, { x: 160, y: 200, time: 1_100 }), false); assert.equal(isDoubleTap(null, first), false); + assert.equal(isDoubleTap(first, { x: 100, y: 200, time: 900 }), false); });