Skip to content

Commit

Permalink
Correct coord property "x" to "y" in isDifferentPointerPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
jdufresne committed May 16, 2024
1 parent d036279 commit 8e80444
Show file tree
Hide file tree
Showing 2 changed files with 21 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
20 changes: 20 additions & 0 deletions tests/pointer/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,23 @@ test('move touch over elements', async () => {
div - click: primary
`)
})

test('move pointer by x coord', async () => {
const {elements, getEventSnapshot, user} = setup('<div></div>')

// Only x changes
await user.pointer([
{keys: '[MouseLeft>]', target: elements[0], coords: {x: 20, y: 20}},
{keys: '[/MouseLeft]', target: elements[0], coords: {x: 40, y: 20}},
])

expect(getEventSnapshot()).toMatchInlineSnapshot(`
Events fired on: div
div - pointerdown
div - mousedown: primary
div - pointerup
div - mouseup: primary
div - click: primary
`)
})

0 comments on commit 8e80444

Please sign in to comment.