🔇 fix: Hide Button Icons from Screen Readers (#10776)
Some checks failed
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled

If you've got a screen reader that is reading out the whole page,
each icon button (i.e., `<button><SVG></button>`) will have both
the button's aria-label read out as well as the title from the
SVG (which is usually just "image").

Since we are pretty good about setting aria-labels, we should instead
use `aria-hidden="true"` on these images, since they are not useful
to be read out.

I don't consider this a comprehensive review of all icons in the app,
but I knocked out all the low hanging fruit in this commit.
This commit is contained in:
Daniel Lew 2025-12-11 15:35:17 -06:00 committed by GitHub
parent b288d81f5a
commit 1143f73f59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
175 changed files with 340 additions and 183 deletions

View file

@ -33,7 +33,7 @@ export default function SourceIcon({
return (
<div className={cn(className, sourceToClassname[FileSources.execute_code] ?? '')}>
<span className="flex items-center justify-center">
<Terminal className="h-3 w-3" />
<Terminal className="h-3 w-3" aria-hidden="true" />
</span>
</div>
);
@ -43,7 +43,7 @@ export default function SourceIcon({
return (
<div className={cn(className, sourceToClassname[source] ?? '')}>
<span className="flex items-center justify-center">
<Type className="h-3 w-3" />
<Type className="h-3 w-3" aria-hidden="true" />
</span>
</div>
);
@ -53,7 +53,7 @@ export default function SourceIcon({
return (
<div className={cn(className, sourceToClassname[source] ?? '')}>
<span className="flex items-center justify-center">
<Database className="h-3 w-3" />
<Database className="h-3 w-3" aria-hidden="true" />
</span>
</div>
);

View file

@ -68,7 +68,7 @@ export const columns: ColumnDef<TFile>[] = [
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
>
{localize('com_ui_name')}
<ArrowUpDown className="ml-2 h-3 w-4 sm:h-4 sm:w-4" />
<ArrowUpDown className="ml-2 h-3 w-4 sm:h-4 sm:w-4" aria-hidden="true" />
</Button>
);
},
@ -107,7 +107,7 @@ export const columns: ColumnDef<TFile>[] = [
className="px-2 py-0 text-xs hover:bg-surface-hover sm:px-2 sm:py-2 sm:text-sm"
>
{localize('com_ui_date')}
<ArrowUpDown className="ml-2 h-3 w-4 sm:h-4 sm:w-4" />
<ArrowUpDown className="ml-2 h-3 w-4 sm:h-4 sm:w-4" aria-hidden="true" />
</Button>
);
},
@ -160,7 +160,7 @@ export const columns: ColumnDef<TFile>[] = [
}
return (
<div className="flex flex-wrap items-center gap-2">
<Database className="icon-sm text-cyan-700" />
<Database className="icon-sm text-cyan-700" aria-hidden="true" />
{localize('com_ui_host')}
</div>
);
@ -204,7 +204,7 @@ export const columns: ColumnDef<TFile>[] = [
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
>
{localize('com_ui_size')}
<ArrowUpDown className="ml-2 h-3 w-4 sm:h-4 sm:w-4" />
<ArrowUpDown className="ml-2 h-3 w-4 sm:h-4 sm:w-4" aria-hidden="true" />
</Button>
);
},

View file

@ -127,7 +127,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
aria-label={localize('com_files_filter_by')}
className={cn('min-w-[40px]', isSmallScreen && 'px-2 py-1')}
>
<ListFilter className="size-3.5 sm:size-4" />
<ListFilter className="size-3.5 sm:size-4" aria-hidden="true" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent

View file

@ -41,9 +41,9 @@ export function SortFilterHeader<TData, TValue>({
>
<span>{title}</span>
{column.getIsFiltered() ? (
<ListFilter className="icon-sm ml-2 text-muted-foreground/70" />
<ListFilter className="icon-sm ml-2 text-muted-foreground/70" aria-hidden="true" />
) : (
<ListFilter className="icon-sm ml-2 opacity-30" />
<ListFilter className="icon-sm ml-2 opacity-30" aria-hidden="true" />
)}
{(() => {
const sortState = column.getIsSorted();
@ -95,7 +95,10 @@ export function SortFilterHeader<TData, TValue>({
column.setFilterValue(value);
}}
>
<ListFilter className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
<ListFilter
className="mr-2 h-3.5 w-3.5 text-muted-foreground/70"
aria-hidden="true"
/>
{filterValue}
</DropdownMenuItem>
);
@ -112,7 +115,7 @@ export function SortFilterHeader<TData, TValue>({
column.setFilterValue(undefined);
}}
>
<FilterX className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
<FilterX className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" aria-hidden="true" />
{localize('com_ui_show_all')}
</DropdownMenuItem>
)}