-
Notifications
You must be signed in to change notification settings - Fork 614
Utilize aria-describedby
on all ActionList
descriptions
#4666
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 all commits
d8cd733
377ef5d
6c00d25
26800fb
69a57f1
a672887
5fad1fd
c62806e
3b4f8c0
9dbc082
57a5034
0b11bc6
baf63b7
cf00630
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 | ||
--- | ||
|
||
ActionList: Adds `aria-labelledby` to `ActionList.TrailingVisual`, making it part of the accessible name of `ActionList.Item` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | |
const labelId = `${itemId}--label` | ||
const inlineDescriptionId = `${itemId}--inline-description` | ||
const blockDescriptionId = `${itemId}--block-description` | ||
const trailingVisualId = `${itemId}--trailing-visual` | ||
const inactiveWarningId = inactive && !showInactiveIndicator ? `${itemId}--warning-message` : undefined | ||
|
||
const ButtonItemWrapper = React.forwardRef(({as: Component = 'button', children, ...props}, forwardedRef) => { | ||
|
@@ -294,10 +295,14 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | |
'data-inactive': inactive ? true : undefined, | ||
'data-loading': loading && !inactive ? true : undefined, | ||
tabIndex: disabled || showInactiveIndicator ? undefined : 0, | ||
'aria-labelledby': `${labelId} ${slots.inlineDescription ? inlineDescriptionId : ''}`, | ||
'aria-describedby': slots.blockDescription | ||
? [blockDescriptionId, inactiveWarningId].join(' ') | ||
: inactiveWarningId, | ||
'aria-labelledby': `${labelId} ${slots.trailingVisual ? trailingVisualId : ''} ${ | ||
slots.inlineDescription ? inlineDescriptionId : '' | ||
}`, | ||
'aria-describedby': | ||
[slots.blockDescription ? blockDescriptionId : undefined, inactiveWarningId ?? undefined] | ||
.filter(String) | ||
.join(' ') | ||
.trim() || undefined, | ||
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. Optional: Don't think we need trim now that we are filtering strings 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. I added this because we'd get |
||
...(includeSelectionAttribute && {[itemSelectionAttribute]: selected}), | ||
role: itemRole, | ||
id: itemId, | ||
|
@@ -327,7 +332,14 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | |
|
||
return ( | ||
<ItemContext.Provider | ||
value={{variant, disabled, inactive: Boolean(inactiveText), inlineDescriptionId, blockDescriptionId}} | ||
value={{ | ||
variant, | ||
disabled, | ||
inactive: Boolean(inactiveText), | ||
inlineDescriptionId, | ||
blockDescriptionId, | ||
trailingVisualId, | ||
}} | ||
> | ||
<LiBox | ||
ref={!buttonSemanticsFeatureFlag || listSemantics ? forwardedRef : null} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,7 +339,7 @@ exports[`NavList renders a simple list 1`] = ` | |
> | ||
<a | ||
aria-current="page" | ||
aria-labelledby=":r2:--label " | ||
aria-labelledby=":r2:--label " | ||
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. Could me make the filtering string on aria-labelledby as well so that we don't get these extra spaces 😅 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. Yes, definitely! I forgot I turned on auto merge 🤣, I can follow up in one of the PRs that I'll make for one of the sev-3 issues! |
||
class="c3 c4" | ||
href="/" | ||
id=":r2:" | ||
|
@@ -362,7 +362,7 @@ exports[`NavList renders a simple list 1`] = ` | |
class="c1 c7" | ||
> | ||
<a | ||
aria-labelledby=":r3:--label " | ||
aria-labelledby=":r3:--label " | ||
class="c3 c4" | ||
href="/about" | ||
id=":r3:" | ||
|
@@ -385,7 +385,7 @@ exports[`NavList renders a simple list 1`] = ` | |
class="c1 c7" | ||
> | ||
<a | ||
aria-labelledby=":r4:--label " | ||
aria-labelledby=":r4:--label " | ||
class="c3 c4" | ||
href="/contact" | ||
id=":r4:" | ||
|
@@ -803,7 +803,7 @@ exports[`NavList renders with groups 1`] = ` | |
> | ||
<a | ||
aria-current="page" | ||
aria-labelledby=":r8:--label " | ||
aria-labelledby=":r8:--label " | ||
class="c7 c8" | ||
href="/getting-started" | ||
id=":r8:" | ||
|
@@ -846,7 +846,7 @@ exports[`NavList renders with groups 1`] = ` | |
class="c5 c11" | ||
> | ||
<a | ||
aria-labelledby=":ra:--label " | ||
aria-labelledby=":ra:--label " | ||
class="c7 c8" | ||
href="/Avatar" | ||
id=":ra:" | ||
|
@@ -1274,7 +1274,7 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav | |
<button | ||
aria-controls=":r27:" | ||
aria-expanded="true" | ||
aria-labelledby=":r26:--label " | ||
aria-labelledby=":r26:--label :r26:--trailing-visual " | ||
class="c3 c4" | ||
id=":r26:" | ||
tabindex="0" | ||
|
@@ -1294,6 +1294,7 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav | |
</span> | ||
<span | ||
class="c1 c8" | ||
id=":r26:--trailing-visual" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
|
@@ -1324,7 +1325,7 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav | |
> | ||
<a | ||
aria-current="page" | ||
aria-labelledby=":r29:--label " | ||
aria-labelledby=":r29:--label " | ||
class="c12 c13" | ||
href="#" | ||
id=":r29:" | ||
|
@@ -1773,7 +1774,7 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t | |
<button | ||
aria-controls=":r21:" | ||
aria-expanded="false" | ||
aria-labelledby=":r20:--label " | ||
aria-labelledby=":r20:--label :r20:--trailing-visual " | ||
class="c3 c4" | ||
id=":r20:" | ||
tabindex="0" | ||
|
@@ -1793,6 +1794,7 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t | |
</span> | ||
<span | ||
class="c1 c8" | ||
id=":r20:--trailing-visual" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
|
@@ -1823,7 +1825,7 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t | |
> | ||
<a | ||
aria-current="page" | ||
aria-labelledby=":r23:--label " | ||
aria-labelledby=":r23:--label " | ||
class="c12 c13" | ||
href="#" | ||
id=":r23:" | ||
|
Uh oh!
There was an error while loading. Please reload this page.