Skip to content

keyboard: only prevent default behavior if all of repeated keydown call Event.preventDefault() #999

@ph-fritsche

Description

@ph-fritsche

Reproduction example

https://codesandbox.io/s/userevent-keyboard-prevent-imf9hv?file=/src/App.test.js

Prerequisites

  1. Render <button>
  2. Add an event handler that calls event.preventDefault() on the last of multiple keydown.
  3. Press space bar

Expected behavior

A click event is dispatched if there is any keydown without a call to event.preventDefault().

Actual behavior

The click event is only dispatched if the last keydown does not prevent default.

User-event version

14.3.0

Environment

Testing Library framework:

JS framework:

Test environment:

DOM implementation:

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions