Skip to content

Cannot tab in react-testing-library #919

Open
@danny-does-stuff

Description

@danny-does-stuff

Summary:

When writing tests using react-testing-library, tabbing does not work properly when inside of a react-modal.

Steps to reproduce:

  1. Render a Modal with some tabbable elements
  2. Try to tab between elements using @testing-library/user-event userEvent.tab()
  3. The focused element does not change 😢

Expected behavior:

The focused element changes when calling userEvent.tab() inside of a react-modal.

Link to example of issue:

https://codesandbox.io/s/xenodochial-mestorf-qx6j8?file=/src/__tests__/index.js

Additional notes:

I'm aware the issue could be in the user-event library, so I made a companion issue over there (clicky). I'm also thinking I could just need more understanding of how the focus trapping is working in react-modal / user-event so I can get them to play together nicely.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions