Skip to content

Typing and tabbing with @testing-library/dom does not fire change event #1281

@fongandrew

Description

@fongandrew

Reproduction example

https://codesandbox.io/p/sandbox/crazy-shape-j8gs37

Prerequisites

  1. userEvent.type(input, "hello")
  2. userEvent.tab()

No change event appears to be fired.

Expected behavior

When a user types something into an input on the browser and tabs away (or otherwise blurs the input), the input will fire a change event if the value is different. But when this is simulated via @testing-library/user-event, this does not happen. Note that we're talking about the browser's actual change event and not the synthetic one that React creates around input events.

Actual behavior

No change event is fired.

User-event version

14.6.1

Environment

Testing Library framework: @testing-library/[email protected]
JS framework: N/A
Test environment: [email protected]
DOM implementation: [email protected]

Additional context

As a workaround, we can manually dispatch a change event / use fireEvent.change. But given @testing-library/user-event's focus on recreating actual user interactions, I'd expect that to happen automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds assessmentThis needs to be looked at by a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions