Skip to content

Commit 5d666ae

Browse files
authored
fix(components): remove duplicate Tag name from Tag removal IconButton accessible name (#1759)
1 parent 34660b0 commit 5d666ae

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

.changeset/proud-peas-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@launchpad-ui/components": patch
3+
---
4+
5+
Remove Tag textValue from Tag removal IconButton aria-label, as it results in the Tag textValue getting included twice in the accessible name of the removal button, such as "Remove tag-name tag-name" instead of "Remove tag-name"

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"quickfix.biome": "explicit",
88
"source.organizeImports.biome": "explicit"
99
},
10-
"editor.tabSize": 2
10+
"editor.tabSize": 2,
11+
"[typescriptreact]": {
12+
"editor.defaultFormatter": "biomejs.biome"
13+
}
1114
}

packages/components/__tests__/TagGroup.spec.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('TagGroup', () => {
1818
expect(screen.getByRole('grid')).toBeVisible();
1919
});
2020

21-
it('renders remove buttons', () => {
21+
it('renders remove buttons with correct accessible names', () => {
2222
render(
2323
<TagGroup onRemove={() => undefined}>
2424
<Label>Label</Label>
@@ -29,10 +29,20 @@ describe('TagGroup', () => {
2929
</TagList>
3030
</TagGroup>,
3131
);
32+
33+
// Verify all buttons are visible
3234
const buttons = screen.getAllByRole('button');
35+
expect(buttons).toHaveLength(3);
3336
for (const button of buttons) {
3437
expect(button).toBeVisible();
3538
}
36-
expect(buttons[0].getAttribute('aria-label')).toBe('Remove One');
39+
40+
// Verify accessible names are correct for each tag
41+
expect(screen.getByRole('button', { name: 'Remove One' })).toBeVisible();
42+
expect(screen.getByRole('button', { name: 'Remove Two' })).toBeVisible();
43+
expect(screen.getByRole('button', { name: 'Remove Three' })).toBeVisible();
44+
45+
// Verify the aria-label attribute is just "Remove"
46+
expect(buttons[0].getAttribute('aria-label')).toBe('Remove');
3747
});
3848
});

packages/components/src/TagGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const Tag = ({ size = 'medium', variant = 'default', ref, ...props }: TagProps)
110110
{children}
111111
{allowsRemoving && (
112112
<IconButton
113-
aria-label={`Remove ${textValue ?? ''}`.trim()}
113+
aria-label="Remove"
114114
size="small"
115115
variant="minimal"
116116
icon="cancel-circle-outline"

0 commit comments

Comments
 (0)