Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(core): remove invalid aria-orientation from ButtonGroup role=group (#3536)

Cindy Zhang3d6390ac39fa
diff --git a/.changeset/buttongroup-aria-orientation.md b/.changeset/buttongroup-aria-orientation.md
new file mode 100644
index 0000000000..8136bc9ba1
--- /dev/null
+++ b/.changeset/buttongroup-aria-orientation.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] ButtonGroup: remove the invalid `aria-orientation` attribute from the `role="group"` element, which was flagged by axe (aria-allowed-attr). Orientation is still reflected via `data-orientation` and drives keyboard navigation and styling, so behavior is unchanged. Also fixes Schedule, which reuses ButtonGroup internally.
+
+@cixzhang
diff --git a/packages/core/src/ButtonGroup/ButtonGroup.test.tsx b/packages/core/src/ButtonGroup/ButtonGroup.test.tsx
index 9481a0aa00..8e92631e90 100644
--- a/packages/core/src/ButtonGroup/ButtonGroup.test.tsx
+++ b/packages/core/src/ButtonGroup/ButtonGroup.test.tsx
@@ -88,17 +88,18 @@ describe('ButtonGroup', () => {
expect(refValue).toBe(screen.getByRole('group'));
});
- it('sets aria-orientation', () => {
+ it('reflects orientation via data-orientation, not aria-orientation', () => {
+ // aria-orientation is not a valid ARIA attribute on role="group"; the
+ // orientation is exposed through data-orientation instead.
const {rerender} = render(
<ButtonGroup label="Actions">
<Button label="Copy" />
</ButtonGroup>,
);
- expect(screen.getByRole('group')).toHaveAttribute(
- 'aria-orientation',
- 'horizontal',
- );
+ let group = screen.getByRole('group');
+ expect(group).not.toHaveAttribute('aria-orientation');
+ expect(group).toHaveAttribute('data-orientation', 'horizontal');
rerender(
<ButtonGroup label="Actions" orientation="vertical">
@@ -106,10 +107,9 @@ describe('ButtonGroup', () => {
</ButtonGroup>,
);
- expect(screen.getByRole('group')).toHaveAttribute(
- 'aria-orientation',
- 'vertical',
- );
+ group = screen.getByRole('group');
+ expect(group).not.toHaveAttribute('aria-orientation');
+ expect(group).toHaveAttribute('data-orientation', 'vertical');
});
it('renders with vertical orientation', () => {
diff --git a/packages/core/src/ButtonGroup/ButtonGroup.tsx b/packages/core/src/ButtonGroup/ButtonGroup.tsx
index fc1f5af9eb..24298463ce 100644
--- a/packages/core/src/ButtonGroup/ButtonGroup.tsx
+++ b/packages/core/src/ButtonGroup/ButtonGroup.tsx
@@ -141,7 +141,6 @@ export function ButtonGroup({
role="group"
aria-label={label}
onKeyDown={handleKeyDown}
- aria-orientation={orientation}
aria-disabled={isDisabled || undefined}
data-testid={testId}
{...mergeProps(