Skip to content

Commit 860ac93

Browse files
authored
Pass aria-label prop to ActionBar toolbar (#6877)
1 parent 4b84948 commit 860ac93

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.changeset/flat-ears-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
In `ActionBar`, `aria-label` now gets added to the `role="toolbar"` element.

packages/react/src/ActionBar/ActionBar.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default meta
2121
type Story = StoryObj<typeof ActionBar>
2222

2323
export const Playground: Story = {
24-
render: args => (
25-
<ActionBar {...args}>
24+
render: ({'aria-labelledby': _, ...args}) => (
25+
<ActionBar {...args} aria-label="Toolbar">
2626
<ActionBar.IconButton icon={BoldIcon} aria-label="Bold"></ActionBar.IconButton>
2727
<ActionBar.IconButton icon={ItalicIcon} aria-label="Italic"></ActionBar.IconButton>
2828
<ActionBar.Divider />

packages/react/src/ActionBar/ActionBar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ const getMenuItems = (
151151
}
152152

153153
export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = props => {
154-
const {size = 'medium', children, 'aria-label': ariaLabel, flush = false, className} = props
154+
const {
155+
size = 'medium',
156+
children,
157+
'aria-label': ariaLabel,
158+
'aria-labelledby': ariaLabelledBy,
159+
flush = false,
160+
className,
161+
} = props
155162

156163
const [childRegistry, setChildRegistry] = useState<ChildRegistry>(() => new Map())
157164

@@ -225,6 +232,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop
225232
className={styles.List}
226233
style={{gap: `${ACTIONBAR_ITEM_GAP}px`}}
227234
aria-label={ariaLabel}
235+
aria-labelledby={ariaLabelledBy}
228236
>
229237
{children}
230238
{menuItemIds.size > 0 && (

0 commit comments

Comments
 (0)