Skip to content

Commit

Permalink
[bug] Compare x against x not y in isDifferentPointerPosition()
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-codaio committed Jul 10, 2024
1 parent d036279 commit f0edaeb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/system/pointer/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions tests/pointer/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ test('drag sequence', async () => {
`)
})

test('drag sequence w/ differing x coordinates', async () => {
const {element, getClickEventsSnapshot, user} = setup(`<div></div>`)

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(`<div></div>`)

Expand Down

0 comments on commit f0edaeb

Please sign in to comment.