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/flat-ears-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

In `ActionBar`, `aria-label` now gets added to the `role="toolbar"` element.
2 changes: 1 addition & 1 deletion packages/react/src/ActionBar/ActionBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Story = StoryObj<typeof ActionBar>

export const Playground: Story = {
render: args => (
<ActionBar {...args}>
<ActionBar {...args} aria-label="Toolbar">
<ActionBar.IconButton icon={BoldIcon} aria-label="Bold"></ActionBar.IconButton>
<ActionBar.IconButton icon={ItalicIcon} aria-label="Italic"></ActionBar.IconButton>
<ActionBar.Divider />
Expand Down
21 changes: 17 additions & 4 deletions packages/react/src/ActionBar/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,14 @@ const overflowEffect = (
}

export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = props => {
const {size = 'medium', children, 'aria-label': ariaLabel, flush = false, className} = props
const {
size = 'medium',
children,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
flush = false,
className,
} = props
const [childWidthArray, setChildWidthArray] = useState<ChildWidthArray>([])
const setChildrenWidth = useCallback((size: ChildSize) => {
setChildWidthArray(arr => {
Expand Down Expand Up @@ -202,7 +209,13 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop
return (
<ActionBarContext.Provider value={{size, setChildrenWidth}}>
<div ref={navRef} className={clsx(className, styles.Nav)} data-flush={flush}>
<div ref={listRef} role="toolbar" className={styles.List}>
<div
ref={listRef}
role="toolbar"
className={styles.List}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
>
{listItems}
{menuItems.length > 0 && (
<ActionMenu>
Expand All @@ -219,7 +232,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop
children: menuItemChildren,
onClick,
icon: Icon,
'aria-label': ariaLabel,
'aria-label': menuItemAriaLabel,
disabled,
} = menuItem.props
return (
Expand All @@ -238,7 +251,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop
<Icon />
</ActionList.LeadingVisual>
) : null}
{ariaLabel}
{menuItemAriaLabel}
</ActionList.Item>
)
}
Expand Down
Loading