-
Notifications
You must be signed in to change notification settings - Fork 646
Add support to ActionList and ActionList.Item for tablist and tab roles
#7109
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
Conversation
🦋 Changeset detectedLatest commit: 011da96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
| // Ensures ActionList.Item retains list item semantics if a valid ARIA role is applied, or if item is inactive | ||
| const listItemSemantics = | ||
| role === 'option' || role === 'menuitem' || role === 'menuitemradio' || role === 'menuitemcheckbox' | ||
| itemRole === 'option' || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just seemed like a bug. We weren't using the inferredItemRole when checking if the item is a list item
| disabled = false, | ||
| inactiveText, | ||
| selected = undefined, | ||
| active = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to also derive this based on the aria-attributes (i.e. active if aria-selected == true)
| ref={listSemantics ? forwardedRef : null} | ||
| data-variant={variant === 'danger' ? variant : undefined} | ||
| data-active={active ? true : undefined} | ||
| data-selectable={includeSelectionAttribute ? true : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this to limit the new CSS selector. Could also gate this behavior behind a FF or prop to limit exposure if needed.
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/6127 |
|
🟢 ci completed with status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for ARIA tablist and tab roles to the ActionList component, enabling it to be used for tab navigation patterns.
Key changes:
- Adds automatic
tabrole inference when ActionList hasrole="tablist" - Updates list item semantics to preserve proper structure for tab roles
- Adds unit tests to verify tab role behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react/src/ActionList/Item.tsx | Adds logic to infer tab role for items within tablists and includes tab role in listItemSemantics check |
| packages/react/src/ActionList/Item.test.tsx | Adds two unit tests verifying tab role is correctly applied |
| .changeset/early-ghosts-enter.md | Changelog entry documenting the new feature |
Comments suppressed due to low confidence (2)
packages/react/src/ActionList/Item.tsx:142
- The
tabrole requiresaria-selectedattribute for proper ARIA semantics. WhenitemRole === 'tab', the code should setinferredSelectionAttribute = 'aria-selected'. This is consistent with other tab implementations in the codebase (TabNav and UnderlinePanels) which usearia-selectedwith tab roles.
/** Infer the proper selection attribute based on the item's role */
let inferredSelectionAttribute: 'aria-selected' | 'aria-checked' | undefined
if (itemRole === 'menuitemradio' || itemRole === 'menuitemcheckbox') inferredSelectionAttribute = 'aria-checked'
else if (itemRole === 'option') inferredSelectionAttribute = 'aria-selected'
packages/react/src/ActionList/Item.tsx:194
- The
selectableRolesarray should include'tab'to ensure that tab elements receive the appropriate selection attributes. Tabs needaria-selectedto indicate which tab is currently active, as seen in TabNav and UnderlinePanels implementations.
const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option']
const includeSelectionAttribute = itemSelectionAttribute && itemRole && selectableRoles.includes(itemRole)
joshblack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh boy, more action list roles 😰 Changes look great so if it works for you then 👍 Makes sense to extend this if we're doing it already for listbox/menu.
Co-authored-by: Josh Black <joshblack@github.com>
|
👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks! |
This change stems from an effort to create a vertical version of UnderlinePanels leveraging an ActionList. The semantic checks in
ActionListprevented therolefrom showing on the right item.Changelog
Changed
ActionListto includetablistandtabitems in order to work with thetab-containerelement.Rollout strategy
Testing & Reviewing
ActionListselection bugs.Merge checklist