mui / mui/material-ui

[Popover] FocusTrap in a Shadow DOM loses the focus

Open
#34,980 9 comments 2 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

component: Popover scope: focus trap type: bug
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Steps to reproduce 🕹

Link to live example:
https://codesandbox.io/s/wandering-framework-25fyeg?file=/demo.tsx

Steps:

  1. Open the Popover and focus the input
  2. Press Tab or Shift+Tab a few times
  3. Notice the focus has escaped the popover
Current behavior 😯

FocusTrap doesn't enforce focus to stay inside it if the component is inside a shadow dom.

Expected behavior 🤔

FocusTrap inside a shadow dom should be working the same way it does outside of a shadow dom.

Context 🔦

No response

Your environment 🌎
npx @mui/envinfo
Reproduces in the latest stable Chrome and Safari. Did not test with other browsers.

  System:
    OS: macOS 13.0
  Binaries:
    Node: 18.11.0 - /opt/homebrew/bin/node
    Yarn: Not Found
    npm: 8.19.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 107.0.5304.87
    Edge: Not Found
    Firefox: Not Found
    Safari: 16.1
  npmPackages:
    @emotion/react: ^11.10.5 => 11.10.5 
    @emotion/styled: ^11.10.5 => 11.10.5 
    @mui/base:  5.0.0-alpha.104 
    @mui/core-downloads-tracker:  5.10.12 
    @mui/icons-material: ^5.10.9 => 5.10.9 
    @mui/material: ^5.10.12 => 5.10.12 
    @mui/private-theming:  5.10.9 
    @mui/styled-engine:  5.10.8 
    @mui/system:  5.10.12 
    @mui/types:  7.2.0 
    @mui/utils:  5.10.9 
    @types/react: ^18.0.24 => 18.0.24 
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    typescript: ^4.8.4 => 4.8.4 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.