Skip to content

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

TypeScript

fix(AvatarGroupOverflow): expose static overflow role (#7736)

심미진38f84f662bc0
diff --git a/.changeset/avatargroupoverflow-exposes-its-static-overflow--2590.md b/.changeset/avatargroupoverflow-exposes-its-static-overflow--2590.md
new file mode 100644
index 0000000000..ad63f55c0d
--- /dev/null
+++ b/.changeset/avatargroupoverflow-exposes-its-static-overflow--2590.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] The static `AvatarGroupOverflow` chip (no `onClick`) is exposed to assistive technology as an image named by its count label ("5 more"). Before, it was a span with an `aria-label` but no role, a name the generic role does not allow, so screen readers could skip the count. This meets WCAG 2.2 SC 4.1.2 Name, Role, Value. Nothing changes visually; the clickable chip stays a button, and a `role` passed by the caller still wins.
+
+@azure-553
diff --git a/packages/core/src/AvatarGroup/AvatarGroupOverflow.test.tsx b/packages/core/src/AvatarGroup/AvatarGroupOverflow.test.tsx
index 9a80e24ea6..07150cdf36 100644
--- a/packages/core/src/AvatarGroup/AvatarGroupOverflow.test.tsx
+++ b/packages/core/src/AvatarGroup/AvatarGroupOverflow.test.tsx
@@ -21,6 +21,29 @@ describe('AvatarGroupOverflow', () => {
expect(overflow).toHaveTextContent('+5');
});
+ it('exposes the static overflow as a named image', () => {
+ render(
+ <AvatarGroup>
+ <Avatar name="Alice" />
+ <AvatarGroupOverflow count={5} />
+ </AvatarGroup>,
+ );
+
+ const overflow = screen.getByRole('img', {name: '5 more'});
+ expect(overflow).toHaveAttribute('role', 'img');
+ });
+
+ it('keeps a caller-supplied role on the static overflow', () => {
+ render(
+ <AvatarGroup>
+ <Avatar name="Alice" />
+ <AvatarGroupOverflow count={5} role="note" />
+ </AvatarGroup>,
+ );
+
+ expect(screen.getByLabelText('5 more')).toHaveAttribute('role', 'note');
+ });
+
it('reflects the group size on the overflow chip', () => {
render(
<AvatarGroup size="lg">
@@ -66,7 +89,7 @@ describe('AvatarGroupOverflow', () => {
</AvatarGroup>,
);
- const overflow = screen.getByLabelText('3 more');
+ const overflow = screen.getByRole('button', {name: '3 more'});
expect(overflow.tagName).toBe('BUTTON');
});
diff --git a/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx b/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx
index 62103c7352..0534fc8e32 100644
--- a/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx
+++ b/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx
@@ -208,6 +208,8 @@ export function AvatarGroupOverflow({
return (
<span
ref={ref}
+ // Before the caller's props so a caller-supplied role still wins.
+ role="img"
{...rest}
aria-label={label}
{...mergeProps(