Skip to content

Commit 192f5fd

Browse files
bryan-codaioph-fritsche
authored andcommitted
fix(pointer): compare x against x not y in isDifferentPointerPosition()
1 parent 63f7468 commit 192f5fd

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/system/pointer/shared.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function isDifferentPointerPosition(
2727
) {
2828
return (
2929
positionA.target !== positionB.target ||
30-
positionA.coords?.x !== positionB.coords?.y ||
30+
positionA.coords?.x !== positionB.coords?.x ||
3131
positionA.coords?.y !== positionB.coords?.y ||
3232
positionA.caret?.node !== positionB.caret?.node ||
3333
positionA.caret?.offset !== positionB.caret?.offset

tests/pointer/drag.ts

+21
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@ test('drag sequence', async () => {
2020
`)
2121
})
2222

23+
test('drag sequence w/ differing x coordinates', async () => {
24+
const {element, getClickEventsSnapshot, user} = setup(`<div></div>`)
25+
26+
await user.pointer([
27+
{keys: '[MouseLeft>]', target: element, coords: {x: 0, y: 0}},
28+
{target: element, coords: {x: 0, y: 0}}, // doesn't actually move, won't show up in snapshot below
29+
{target: element, coords: {x: 10, y: 0}}, // will show up in snapshot below
30+
'[/MouseLeft]',
31+
])
32+
33+
expect(getClickEventsSnapshot()).toMatchInlineSnapshot(`
34+
pointerdown - pointerId=1; pointerType=mouse; isPrimary=true
35+
mousedown - button=0; buttons=1; detail=1
36+
pointermove - pointerId=1; pointerType=mouse; isPrimary=true
37+
mousemove - button=0; buttons=1; detail=0
38+
pointerup - pointerId=1; pointerType=mouse; isPrimary=true
39+
mouseup - button=0; buttons=0; detail=1
40+
click - button=0; buttons=0; detail=1
41+
`)
42+
})
43+
2344
test('drag touch', async () => {
2445
const {element, getClickEventsSnapshot, user} = setup(`<div></div>`)
2546

0 commit comments

Comments
 (0)