Reproduction example
https://codesandbox.io/s/adoring-browser-h5lzcy?file=/src/App.test.js
Prerequisites
- Render element with mousemove handler
- Move pointer with
coords: {clientX: 1}
- Move pointer again with
coords: {clientX: 2}
Expected behavior
Two mousemove events with clientX values of 1 and 2.
Actual behavior
A single event with clientX 1.
User-event version
14.4.3
Environment
No response
Additional context
Relevant
isDifferentPointerPosition only compares x and y.
|
export function isDifferentPointerPosition( |
|
positionA: PointerPosition, |
|
positionB: PointerPosition, |
|
) { |
|
return ( |
|
positionA.target !== positionB.target || |
|
positionA.coords?.x !== positionB.coords?.y || |
|
positionA.coords?.y !== positionB.coords?.y || |
|
positionA.caret?.node !== positionB.caret?.node || |
|
positionA.caret?.offset !== positionB.caret?.offset |
|
) |
|
} |
initMouseEvent uses x/y as defaults for clientX/clientY.
|
function initMouseEvent( |
|
event: MouseEvent, |
|
{ |
|
x, |
|
y, |
|
screenX, |
|
screenY, |
|
clientX = x, |
|
clientY = y, |
|
button, |
|
buttons, |
|
relatedTarget, |
|
}: MouseEventInit & {x?: number; y?: number}, |
|
) { |
|
assignProps(event, { |
|
screenX: sanitizeNumber(screenX), |
|
screenY: sanitizeNumber(screenY), |
|
clientX: sanitizeNumber(clientX), |
|
x: sanitizeNumber(clientX), |
|
clientY: sanitizeNumber(clientY), |
|
y: sanitizeNumber(clientY), |
|
button: sanitizeNumber(button), |
|
buttons: sanitizeNumber(buttons), |
|
relatedTarget, |
|
}) |
|
} |
x & y are specified as aliases of clientX/Y, suggesting the defaults should go the other way around.
From JSDOM@22, x & y will alias clientX/Y per spec:
https://github.com/jsdom/jsdom/blob/a39e0ec4ce9a8806692d986a7ed0cd565ec7498a/lib/jsdom/living/events/MouseEvent-impl.js#L9-L15
Related: page/offsetX/Y are defined as properties of PointerCoords but cannot be set on MouseEvent. Depending on wether these props are supported or not, they should either be included in the pointer difference check or removed.
Reported in: #1037
Workaround
Use x/y for coords:
await view.user.pointer({
coords: {
x: 1,
y: 1,
},
})
Reproduction example
https://codesandbox.io/s/adoring-browser-h5lzcy?file=/src/App.test.js
Prerequisites
coords: {clientX: 1}coords: {clientX: 2}Expected behavior
Two
mousemoveevents with clientX values of 1 and 2.Actual behavior
A single event with clientX 1.
User-event version
14.4.3
Environment
No response
Additional context
Relevant
isDifferentPointerPositiononly comparesxandy.user-event/src/system/pointer/shared.ts
Lines 24 to 35 in 7a305de
initMouseEventusesx/yas defaults forclientX/clientY.user-event/src/event/createEvent.ts
Lines 180 to 205 in 7a305de
x & y are specified as aliases of clientX/Y, suggesting the defaults should go the other way around.
From JSDOM@22, x & y will alias clientX/Y per spec:
https://github.com/jsdom/jsdom/blob/a39e0ec4ce9a8806692d986a7ed0cd565ec7498a/lib/jsdom/living/events/MouseEvent-impl.js#L9-L15
Related: page/offsetX/Y are defined as properties of
PointerCoordsbut cannot be set on MouseEvent. Depending on wether these props are supported or not, they should either be included in the pointer difference check or removed.Reported in: #1037
Workaround
Use
x/yfor coords: