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

Drawer close triggers an error in Chrome (sometimes) #2283

Open
nomve opened this issue Nov 25, 2024 · 2 comments
Open

Drawer close triggers an error in Chrome (sometimes) #2283

nomve opened this issue Nov 25, 2024 · 2 comments
Labels
bug Things that aren't working right in the library.

Comments

@nomve
Copy link

nomve commented Nov 25, 2024

Describe the bug

When closing the drawer, I can sometimes observe the following error in the console.

Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.
Element with focus: button
Ancestor with aria-hidden:  <div part=​"panel" class=​"drawer__panel" role=​"dialog" aria-modal=​"true" tabindex=​"0" aria-hidden=​"true" aria-labelledby=​"title">​flex<!--?lit$790917313$--><header part=​"header" class=​"drawer__header">​…​</header>​flex<slot part=​"body" class=​"drawer__body">​…​</slot>​<footer part=​"footer" class=​"drawer__footer">​…​</footer>​</div>​

To Reproduce

Steps to reproduce the behavior:

  1. Use Chrome (at least thus far only reproduced there)
  2. open the drawer
  3. close the drawer
  4. from time to time the bug will appear

Demo

https://shoelace.style/components/drawer

Screenshots

Screenshot 2024-11-25 at 16 38 23

Browser / OS

  • OS: Mac (possibly others)
  • Browser: Chrome
  • Browser version: 131.0.6778.86
@nomve nomve added the bug Things that aren't working right in the library. label Nov 25, 2024
@nomve
Copy link
Author

nomve commented Nov 26, 2024

the issue appears to be a child element that still has focus, so the error gets thrown when drawer attempts to set aria-hidden="true"

seems to be fixed with document.activeElement?.blur() when setting open to false on the drawer. ymmv

@chdenat
Copy link

chdenat commented Dec 1, 2024

Got the same on my app where I'm using a lot of drawers.

Thanks @nomve for the workaround, I can confirm that it fixes the problem.

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