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

Allow setting tabIndex on the Tab.Panel #2214

Merged
merged 2 commits into from
Jan 26, 2023
Merged

Allow setting tabIndex on the Tab.Panel #2214

merged 2 commits into from
Jan 26, 2023

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Jan 26, 2023

This PR adds the ability to override the tabIndex of the Tab.Panel.

The problem:

Right now the Tab.Panel will always be focusable this allows assistive technology to know that the moment you press tab that you are in a tabpanel container.

However, it can be that your Tab.Panel only consists of focusable elements (like links, buttons, ...), which means that you have to tab twice to get to the first focusable element. Sometimes you don't want this behaviour and just want to go straight to the first item, even if this means that we potentially skip elements (like paragraphs, images, ...).

Potential solutions:

  • Keep the current implementation, this will require you to tab twice. But assistive technology will still know the proper boundaries.
  • Automatically focus the first focusable element if the Tab.Panel includes focusable elements and make the Tab.Panel itself have a tabIndex=-1. The downside here is that you potentially skip a lot of information (like paragraphs). This is what React Aria does (https://react-spectrum.adobe.com/react-aria/useTabList.html#focusable-content), but for us that will technically result in a breaking change.
  • Allow to set the tabIndex and opt-in this behaviour and skip the focus of the Tab.Panel itself.

We currently implemented the 3rd option where it is opt-in using the tabIndex prop. This way you can technically break accessibility if you have important paragraphs before the first focusable element.

Resolves: #2110

@vercel
Copy link

vercel bot commented Jan 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 26, 2023 at 4:11PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 26, 2023 at 4:11PM (UTC)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unmount="false" breaks tabindex="-1"
1 participant