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

Fix: Enable tabbing to tag remove buttons #8002

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kirilMatsiuk
Copy link

This PR fixes issue #7483 by improving keyboard accessibility for tag remove buttons.

Changes made:

  • Added keyboardNavigationBehavior: 'tab' to useTagGroup
  • Removed delete rowProps.onKeyDownCapture from useTag
  • Removed excludeFromTabOrder: true from useTag
  • Updated tests to verify correct keyboard navigation

These changes allow users to tab from a tag to its remove button, making the remove functionality accessible via keyboard. Arrow keys still work for navigating between tags.

Before this fix, keyboard users couldn't access the remove buttons via tab navigation, making it impossible to remove tags using only a keyboard.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

  1. Navigate to the Tag component example in the storybook
  2. Use keyboard navigation to focus on a tag
  3. Press Tab to verify focus moves to the remove button (X)
  4. Press Enter/Space to verify the tag can be removed
  5. Verify that arrow keys still work to navigate between different tags

🧢 Your Project:

Thomson Reuters - Contributing to improve React Spectrum accessibility

@yihuiliao
Copy link
Member

Thanks for the PR! You'll need to sign the CLA for it the PR to pass

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, I added a few more higher level tests to verify RAC and interactions between the TagGroup and other expected components continue to work

One interesting thing I found is that a Tooltip around a Tag with a removable button will still show the tooltip even if focus is on the remove button instead. I am unsure how we want to handle this one. Will require further team discussion. It's not something you have done though, it's just come up as a result of the work. I'm still approving.

await user.tab({shift: true});
expect(document.activeElement).toBe(tags[1]);

// TODO: Fix, this is going to the previous tag's remove button instead of to the gridlist item
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a test case that's broken, however, I don't think it's due to any of your work, I think this just surfaced it. If you want to have a look go ahead.

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.

3 participants