Skip to content

The keydown.Tab behaviour handler assumes that the event target will always be the origin for determining focus #1188

@andrewhayward

Description

@andrewhayward

Reproduction example

https://codesandbox.io/p/devbox/lgshc5

Prerequisites

  1. Add an onKeyDown handler to a focusable node
  2. Inside the handler, change the focused node to something else
  3. Include a simulated tab keypress in a test (using user.tab() or a lower level method)

Expected behavior

The Tab keydown behaviour handler should use the currently focused element as the source for determining the tab destination.

Actual behavior

The Tab keydown behaviour handler uses the event target as the source for determining the tab destination.

User-event version

14.5.2

Environment

No response

Additional context

This is niche behaviour, but is used to create focus traps, etc, to constrain tabbing. This may well be causing #820.

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