Skip to content

User Events: keyboard does not target focused element with shadow dom #1153

@enjoythelive1

Description

@enjoythelive1

Reproduction example

https://codesandbox.io/s/trusting-panka-gvg259

Prerequisites

  1. Render an element with an open shadow dom
  2. Focus said element
  3. Use keyboard to trigger keys

Expected behavior

The focused element should register the keyboard events

Actual behavior

The element does not register the keyboard events

User-event version

^14.4.3

Environment

Testing Library framework: @testing-library/dom@9.3.1
JS framework: lit@2.7.5
Test environment: jest@29.5.0
DOM implementation: jsdom@20.0.3

Additional context

I identified that the issue is that when getActiveElement gets an element with shadowDom, it gets the active element of the shadowDom. But, the element with shadow dom could be the active one, even if no shadow children are active (tabindex). Then it returns null, instead of returning the element.

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