Skip to content

Commit

Permalink
LabelGroup: Update "toggle" accessible name to include visual text (#…
Browse files Browse the repository at this point in the history
…4910)

* Update `LabelGroup` truncate button accName

* Add changeset
  • Loading branch information
TylerJDev authored Sep 13, 2024
1 parent af7f589 commit c2e4d5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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>
<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

0 comments on commit c2e4d5e

Please sign in to comment.