Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dialog] Focus trap does not work properly when <sl-dialog> is in a shadow root #709

Closed
pablo-abc opened this issue Mar 18, 2022 · 1 comment
Assignees
Labels
bug Things that aren't working right in the library.

Comments

@pablo-abc
Copy link

Describe the bug

Rendering and opening an <sl-dialog> inside of a shadow root does not seem to play nice with the focus trap. I can tab out of the dialog into elements underneath it.

The scroll-lock also does not seem to work nicely when inside a shadow root (I can still scroll the content underneath)t. But this is inconsistent and I did not manage to reproduce it in a simple example. Mentioning it here just in case it's something similar to the focus trap. But might as well be something in my project.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Lit project
  2. Add shoelace as a dependency (or via CDN)
  3. Use the example code from the documentation
  4. Open the dialog and press tab. The focus will move to the button underneath.

Demo

Reproduction on CodeSandbox

Browser / OS

  • OS: Mac
  • Browse:r Safari and Firefox
  • Browser version: 15.1 and 99.0beta
@pablo-abc pablo-abc added the bug Things that aren't working right in the library. label Mar 18, 2022
@claviska
Copy link
Member

Nice catch, and thanks for the repro. I was able to repro and update the modal utility to trap focus a bit differently which is more reliable and solves for the use case you provided.

This fix will be available in the next beta release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

2 participants