Skip to content

Commit 44d9356

Browse files
authored
fix(site): remove redundant alt text to prevent duplicated accessible names (#19087)
## Description Removes the redundant `alt` text in the `Combobox` component to prevent screen readers from announcing duplicated names (e.g. "Rust Rust"). ## Changes * Remove redundant `alt` text from `Combobox` `ExternalImage` * Update `Combobox` tests accordingly Related to: #19063 (comment)
1 parent 4bced62 commit 44d9356

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

site/src/components/Combobox/Combobox.stories.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ export const SearchAndFilter: Story = {
103103
screen.queryByRole("option", { name: "Kotlin" }),
104104
).not.toBeInTheDocument();
105105
});
106-
// Accessible name includes both image alt text and text content: "Rust Rust"
107-
await userEvent.click(screen.getByRole("option", { name: "Rust Rust" }));
106+
await userEvent.click(screen.getByRole("option", { name: "Rust" }));
108107
},
109108
};
110109

@@ -138,11 +137,9 @@ export const ClearSelectedOption: Story = {
138137
await userEvent.click(canvas.getByRole("button"));
139138
// const goOption = screen.getByText("Go");
140139
// First select an option
141-
// Accessible name includes both image alt text and text content: "Go Go"
142-
await userEvent.click(await screen.findByRole("option", { name: "Go Go" }));
140+
await userEvent.click(await screen.findByRole("option", { name: "Go" }));
143141
// Then clear it by selecting it again
144-
// Accessible name includes both image alt text and text content: "Go Go"
145-
await userEvent.click(await screen.findByRole("option", { name: "Go Go" }));
142+
await userEvent.click(await screen.findByRole("option", { name: "Go" }));
146143

147144
await waitFor(() =>
148145
expect(canvas.getByRole("button")).toHaveTextContent("Select option"),

site/src/components/Combobox/Combobox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const Combobox: FC<ComboboxProps> = ({
124124
<ExternalImage
125125
className="w-4 h-4 object-contain"
126126
src={option.icon}
127-
alt={option.displayName}
127+
alt=""
128128
/>
129129
) : (
130130
/* Placeholder for missing icon to maintain layout consistency */

0 commit comments

Comments
 (0)