Skip to content

userEvent.pointer sets incorrect button and buttons values #1083

@illandril

Description

@illandril

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions