From f0edaeb7812c560ccff9b7cb9ae099d769260021 Mon Sep 17 00:00:00 2001 From: Bryan Jensen Date: Wed, 10 Jul 2024 12:03:45 -0700 Subject: [PATCH] [bug] Compare `x` against `x` not `y` in `isDifferentPointerPosition()` --- src/system/pointer/shared.ts | 2 +- tests/pointer/drag.ts | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/system/pointer/shared.ts b/src/system/pointer/shared.ts index 04ef8eda..a00bb441 100644 --- a/src/system/pointer/shared.ts +++ b/src/system/pointer/shared.ts @@ -27,7 +27,7 @@ export function isDifferentPointerPosition( ) { return ( positionA.target !== positionB.target || - positionA.coords?.x !== positionB.coords?.y || + positionA.coords?.x !== positionB.coords?.x || positionA.coords?.y !== positionB.coords?.y || positionA.caret?.node !== positionB.caret?.node || positionA.caret?.offset !== positionB.caret?.offset diff --git a/tests/pointer/drag.ts b/tests/pointer/drag.ts index 5414369a..972749af 100644 --- a/tests/pointer/drag.ts +++ b/tests/pointer/drag.ts @@ -20,6 +20,27 @@ test('drag sequence', async () => { `) }) +test('drag sequence w/ differing x coordinates', async () => { + const {element, getClickEventsSnapshot, user} = setup(`
`) + + await user.pointer([ + {keys: '[MouseLeft>]', target: element, coords: {x: 0, y: 0}}, + {target: element, coords: {x: 0, y: 0}}, // doesn't actually move, won't show up in snapshot below + {target: element, coords: {x: 10, y: 0}}, // will show up in snapshot below + '[/MouseLeft]', + ]) + + expect(getClickEventsSnapshot()).toMatchInlineSnapshot(` + pointerdown - pointerId=1; pointerType=mouse; isPrimary=true + mousedown - button=0; buttons=1; detail=1 + pointermove - pointerId=1; pointerType=mouse; isPrimary=true + mousemove - button=0; buttons=1; detail=0 + pointerup - pointerId=1; pointerType=mouse; isPrimary=true + mouseup - button=0; buttons=0; detail=1 + click - button=0; buttons=0; detail=1 + `) +}) + test('drag touch', async () => { const {element, getClickEventsSnapshot, user} = setup(`
`)