Skip to content
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 sets incorrect button and buttons values #1083

Closed
illandril opened this issue Dec 9, 2022 · 1 comment · Fixed by #1219
Closed

userEvent.pointer sets incorrect button and buttons values #1083

illandril opened this issue Dec 9, 2022 · 1 comment · Fixed by #1219
Labels
bug Something isn't working

Comments

@illandril
Copy link
Contributor

Reproduction example

https://codesandbox.io/s/goofy-swanson-03q1nc?file=/src/App.js

Prerequisites

  1. <button>Click me</button>
  2. `document.querySelector('button').addEventListener('pointerDown', (e) => console.log(e.button, e.buttons))
  3. await user.pointer({ keys: '[MouseLeft]', target: screen.getByRole('button') })
  4. await user.pointer({ keys: '[MouseRight]', target: screen.getByRole('button') })
  5. await user.pointer({ keys: '[MouseMiddle]', target: screen.getByRole('button') })

Expected behavior

PointerEvent sets event.button and event.buttons correctly.

https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events#determining_button_states

Actual behavior

Both event.button and event.buttons are always 0.

Note: Changing the event to mouseDown gives correct values for the equivalent MouseEvent.

User-event version

14.1.1

Environment

Testing Library framework:

JS framework:

Test environment:

DOM implementation:

Additional context

No response

@illandril illandril added bug Something isn't working needs assessment This needs to be looked at by a team member labels Dec 9, 2022
@ph-fritsche ph-fritsche removed the needs assessment This needs to be looked at by a team member label Dec 15, 2022
@clarkdo
Copy link

clarkdo commented Mar 5, 2024

Any luck on this bug ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants