-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
userEvent.pointer does not set the button and buttons properties #926
Comments
Thanks for the report. ❤️ We add the
This is an issue with the environment not implementing We already apply a workaround for coordinates and other properties here and should maybe add user-event/src/event/createEvent.ts Lines 40 to 45 in ef826a4
The following workaround fixes the issue: if (!window.PointerEvent) {
window.PointerEvent = window.MouseEvent
} https://codesandbox.io/s/dreamy-firefly-xf3zke?file=/src/App.test.js:45-117 |
Thanks for the explanation and the suggested workaround! |
🎉 This issue has been resolved in version 14.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@all-contributors add @alkstal bug |
I've put up a pull request to add @alkstal! 🎉 |
Reproduction example
https://codesandbox.io/s/misty-haze-n45bf4?file=/src/App.js
Prerequisites
<button>Touch me</button>
Expected behavior
PointerEvent
setsevent.button
andevent.buttons
to allow us to figure out which button was used.https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events#determining_button_states
As an example, if the left mouse button was used, the
pointerup
eventevent.button
is0
.Actual behavior
The
PointerEvent
created byuserEvent.pointer()
does not assignevent.button
orevent.buttons
, so both areundefined
in a event handler.This means event handlers using these properties don't work under test.
User-event version
14.0.4
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
No response
The text was updated successfully, but these errors were encountered: