fix: give the search chips' remove button a name

This commit is contained in:
Linus Rath
2026-11-03 06:06:57 +01:00
parent 65d7f96979
commit a3e4d97efe
2 changed files with 4 additions and 2 deletions
@@ -18,8 +18,7 @@ describe('SearchChips', () => {
/>,
);
const chip = screen.getByText('From Alice').parentElement!;
fireEvent.click(chip.querySelector('button')!);
fireEvent.click(screen.getByRole('button', { name: /remove_filter/ }));
expect(onRemoveFilter).toHaveBeenCalledWith('pluginFilter');
});
});
+3
View File
@@ -19,6 +19,7 @@ export function SearchChips({
className,
}: SearchChipsProps) {
const t = useTranslations("advanced_search");
const tChip = useTranslations("plugin_list");
const chips: { key: keyof SearchFilters; label: string; value: string }[] = [];
@@ -90,6 +91,8 @@ export function SearchChips({
<button
type="button"
onClick={() => onRemoveFilter(chip.key)}
aria-label={tChip("remove_filter", { label: chip.label })}
title={tChip("remove_filter", { label: chip.label })}
className="-my-1 -me-1 p-1.5 rounded-full hover:bg-primary/20 transition-colors"
>
<X className="w-3 h-3" />