Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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/curvy-goats-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Include current selected menu item in accessible name when using an `aria-label` in `SegmentedControl`
5 changes: 4 additions & 1 deletion packages/react/src/SegmentedControl/SegmentedControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ const Root: React.FC<React.PropsWithChildren<SegmentedControlProps>> = ({
The aria-label is only provided as a backup when the designer or engineer neglects to show a label for the SegmentedControl.
The best thing to do is to have a visual label who's id is referenced using the `aria-labelledby` prop.
*/}
<ActionMenu.Button aria-label={ariaLabel} leadingVisual={getChildIcon(selectedChild)}>
<ActionMenu.Button
aria-label={ariaLabel && `${getChildText(selectedChild)}, ${ariaLabel}`}
leadingVisual={getChildIcon(selectedChild)}
>
{getChildText(selectedChild)}
</ActionMenu.Button>
<ActionMenu.Overlay aria-labelledby={ariaLabelledby}>
Expand Down