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

LabelGroup: Update "toggle" accessible name to include visual text #4910

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breezy-boxes-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Changes the accessible name of the "toggle" button in `LabelGroup` to contain the visual label
6 changes: 2 additions & 4 deletions packages/react/src/LabelGroup/LabelGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ const InlineToggle: React.FC<{
hiddenItemIds,
isOverflowShown,
showAllTokensInline,
totalLength,
}) =>
isOverflowShown ? (
<Button ref={collapseButtonRef} onClick={collapseInlineExpandedChildren} size="small" variant="invisible">
Show less
</Button>
) : hiddenItemIds.length ? (
<Button ref={expandButtonRef} variant="invisible" size="small" onClick={showAllTokensInline}>
<VisuallyHidden>Show all {totalLength}</VisuallyHidden>
<VisuallyHidden>Show +{hiddenItemIds.length} more</VisuallyHidden>
Copy link
Member

Choose a reason for hiding this comment

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

Random question, what does including + here do? Is this changing how it's announced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't really change much. For all the screen readers I tested with (NVDA, VoiceOver, JAWS) they all announced "Show plus 11 more". It would be preferable for it to say "11 plus", but then we'd need to move the + in the visual text to be after the number (e.g. 11+).

<span aria-hidden="true">+{hiddenItemIds.length}</span>
</Button>
) : null
Expand All @@ -106,7 +105,6 @@ const OverlayToggle: React.FC<
openOverflowOverlay,
overlayPaddingPx,
overlayWidth,
totalLength,
}) =>
hiddenItemIds.length ? (
<AnchoredOverlay
Expand All @@ -123,7 +121,7 @@ const OverlayToggle: React.FC<
alignmentOffset={overlayPaddingPx * -1}
renderAnchor={props => (
<Button variant="invisible" size="small" {...props} ref={expandButtonRef}>
<VisuallyHidden>Show all {totalLength}</VisuallyHidden>
<VisuallyHidden>Show +{hiddenItemIds.length} more</VisuallyHidden>
<span aria-hidden="true">+{hiddenItemIds.length}</span>
</Button>
)}
Expand Down
Loading