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

TreeGrid: set initial tabindex attributes for the roving tabindex #69320

Open
2 of 6 tasks
afercia opened this issue Feb 26, 2025 · 0 comments
Open
2 of 6 tasks

TreeGrid: set initial tabindex attributes for the roving tabindex #69320

afercia opened this issue Feb 26, 2025 · 0 comments
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Feb 26, 2025

Description

Noticed while working on #69147 / #69190

The TreeGrid roving tabindex inplementation is within the RovingTabIndexItem component and works in a way that the tabinxed attributes are set only when one of the items in the tree grid receives focus.

This means that on initial first rendering, all the items are focusable. I'm not sure this is ideal because it may lead to problems when other components manage focus on the tree grid or other components that wrap it, as noticed in #69147.

To remind what an ARIA widget with roving tabindex is supposed to do:

  • Only one item should be tabbable at a time.
  • Navigation through items is implemented with arrow keys.
  • When tabbing away from the widget and then tabbing into it again, the roving tabindex 'remembers' what the last tabbable item was so that keyboard users land on the last focused item.

However, on first render, all items are focusable and tabbable because none of them has a tabindex attribute set, yet.

Ideally, also on first render there should be only one focusable/tabbable item. That is: all the items should have a tabindex="-1" attribute except the first one that should have a tabindex="0" instead. Optionally, the initial tabbable item should be configurable via a prop.

Step-by-step reproduction instructions

  • Go to the storybook at https://wordpress.github.io/gutenberg/?path=/story/components-experimental-treegrid--default
  • The storybook example shows a grid with buttons and input fields.
  • Do not interact with any of the items yet.
  • Inspect the DOM and observe that none of the buttons / inputs has any tabindex attribute.
  • Click one of the buttons or one of the inputs.
  • Observe the one you clicked gets a tabindex="0" attribute.
  • Observe all the other buttons and inputs get a tabindex="-1" attribute.
  • Expected: all the buttons to have a tabindex attribute also on first render.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@afercia afercia added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended labels Feb 26, 2025
@afercia afercia changed the title TreeGrid: set initial tabindex attributes for hte roving tabindex TreeGrid: set initial tabindex attributes for the roving tabindex Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

1 participant