-
Notifications
You must be signed in to change notification settings - Fork 673
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
Changes from 4 commits
4e1a797
bef3a24
1f56765
bfd689e
239c3c0
3297ba6
0314874
9dd81ff
011da96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@primer/react': patch | ||
| --- | ||
|
|
||
| Add support to ActionList for 'tablist' and 'tab' roles | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,8 @@ const UnwrappedItem = <As extends React.ElementType = 'li'>( | |
| else inferredItemRole = 'menuitem' | ||
| } else if (listRole === 'listbox') { | ||
| if (selectionVariant !== undefined && !role) inferredItemRole = 'option' | ||
| } else if (listRole === 'tablist') { | ||
| inferredItemRole = 'tab' | ||
| } | ||
|
|
||
| const itemRole = role || inferredItemRole | ||
|
|
@@ -142,7 +144,11 @@ const UnwrappedItem = <As extends React.ElementType = 'li'>( | |
| const itemSelectionAttribute = selectionAttribute || inferredSelectionAttribute | ||
| // 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' || | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just seemed like a bug. We weren't using the |
||
| itemRole === 'menuitem' || | ||
| itemRole === 'menuitemradio' || | ||
| itemRole === 'menuitemcheckbox' || | ||
| itemRole === 'tab' | ||
|
|
||
| const listRoleTypes = ['listbox', 'menu', 'list'] | ||
| const listSemantics = (listRole && listRoleTypes.includes(listRole)) || inactive || listItemSemantics | ||
|
|
@@ -249,6 +255,7 @@ const UnwrappedItem = <As extends React.ElementType = 'li'>( | |
| ref={listSemantics ? forwardedRef : null} | ||
| data-variant={variant === 'danger' ? variant : undefined} | ||
| data-active={active ? true : undefined} | ||
| data-selectable={includeSelectionAttribute ? true : undefined} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| data-inactive={inactiveText ? true : undefined} | ||
| data-has-subitem={slots.subItem ? true : undefined} | ||
| data-has-description={slots.description ? true : false} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.