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

sl-drawer issues when using keyboard navigation #2018

Open
schilchSICKAG opened this issue May 16, 2024 · 1 comment
Open

sl-drawer issues when using keyboard navigation #2018

schilchSICKAG opened this issue May 16, 2024 · 1 comment
Labels
bug Things that aren't working right in the library. fixed-in-wa This issue has been fixed or isn't relevant to Web Awesome.

Comments

@schilchSICKAG
Copy link
Contributor

schilchSICKAG commented May 16, 2024

Describe the bug

When using keyboard navigation in <sl-drawer>, you will get one extra tabbable element because drawer__panel has a tabindex set to 0.

To Reproduce

Steps to reproduce the behavior:

Open this codepen. Navigate the pen via keyboard. Do not click the Danger Button. During navigation, you will have a highlight of:

  1. Close-Icon
  2. Button 1
  3. Button 2
  4. Close Button
  5. NOTHING (WRONG) (document.activeElement points to sl-drawer)
  6. Close-Button

The issue here is the applied tabindex="0" for the drawer__panel element.

Suggested fix: Remove the tabindex value. Demo:

As above, but click the danger button before tabbing. Expected highlight is now:

  1. Close-Icon
  2. Button 1
  3. Button 2
  4. Close Button
  5. Close-Icon

Demo

Codepen available at https://codepen.io/schilchSICKAG/pen/OJYygjK?editors=1001

Screenshots

If applicable, add screenshots to help explain the bug.

Browser / OS

  • OS: [e.g. Mac, Windows] ALL
  • Browser: [e.g. Chrome, Firefox, Safari] ALL
  • Browser version: [e.g. 22] ALL

Additional information

I do not know why the tabindex="0" is set on the element at all. The drawer__overlay already has an index of -1, so this should not be an issue? Would be happy to provide a PR for this :)

@schilchSICKAG schilchSICKAG added the bug Things that aren't working right in the library. label May 16, 2024
@claviska
Copy link
Member

The zero tab index gives us a guaranteed element to focus on when the drawer opens. We're switching to the native <dialog> element for dialogs and drawers in Web Awesome. This will let us remove a ton of focus trap logic that's been difficult to maintain.

Unfortunately, <dialog> wasn't well-supported when these components were originally created, but with the 3.0 release in the works we're finally able to get things like this fixed.

@claviska claviska added the fixed-in-wa This issue has been fixed or isn't relevant to Web Awesome. label Oct 28, 2024
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. fixed-in-wa This issue has been fixed or isn't relevant to Web Awesome.
Projects
None yet
Development

No branches or pull requests

2 participants