Skip to content

Commit f0b2691

Browse files
committed
fix(webapp): enforce accessible control names
1 parent 3a8a499 commit f0b2691

8 files changed

Lines changed: 18 additions & 11 deletions

File tree

.oxlintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@
7777
"jsx-a11y/alt-text": "error",
7878
"jsx-a11y/aria-role": "error",
7979
"jsx-a11y/click-events-have-key-events": "off",
80-
"jsx-a11y/control-has-associated-label": "off",
80+
"jsx-a11y/control-has-associated-label": [
81+
"error",
82+
{
83+
"depth": 4,
84+
"ignoreElements": ["audio", "canvas", "embed", "input", "textarea", "tr", "td", "video"]
85+
}
86+
],
8187
"jsx-a11y/label-has-associated-control": "error",
8288
"jsx-a11y/no-autofocus": "off",
8389
"jsx-a11y/no-noninteractive-element-interactions": "off",

apps/webapp/app/components/code/ChartConfigPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ function SeriesColorPicker({
568568
<PopoverTrigger asChild>
569569
<button
570570
type="button"
571+
aria-label="Change series color"
571572
className="shrink-0 rounded p-0.5 hover:bg-background-raised"
572573
title="Change series color"
573574
>

apps/webapp/app/components/primitives/Select.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,17 +572,20 @@ export interface SelectButtonItemProps extends Omit<Ariakit.SelectItemProps, "on
572572
icon?: React.ReactNode;
573573
checkIcon?: React.ReactNode;
574574
shortcut?: ShortcutDefinition;
575+
accessibleLabel: string;
575576
onClick: React.ComponentProps<"button">["onClick"];
576577
}
577578

578579
export function SelectButtonItem({
579580
checkIcon = <Ariakit.SelectItemCheck className="size-8 flex-none text-white" />,
581+
accessibleLabel,
580582
onClick,
581583
...props
582584
}: SelectButtonItemProps) {
583585
const render = (
584586
<button
585587
type="button"
588+
aria-label={accessibleLabel}
586589
onClick={onClick}
587590
className={cn("block w-full text-left", selectItemClasses, props.className)}
588591
/>

apps/webapp/app/components/primitives/charts/ChartLegendCompound.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,10 @@ type ViewAllDataRowProps = {
302302

303303
function ViewAllDataRow({ remainingCount, onViewAll }: ViewAllDataRowProps) {
304304
return (
305-
<div
305+
<button
306+
type="button"
306307
className="relative flex w-full cursor-pointer items-center justify-between gap-2 rounded px-2 py-1 transition hover:bg-background-dimmed"
307308
onClick={onViewAll}
308-
role="button"
309-
tabIndex={0}
310-
onKeyDown={(e) => {
311-
if (e.key === "Enter" || e.key === " ") {
312-
e.preventDefault();
313-
onViewAll?.();
314-
}
315-
}}
316309
>
317310
<div className="relative flex w-full items-center justify-between gap-3">
318311
<div className="flex items-center gap-1.5">
@@ -321,7 +314,7 @@ function ViewAllDataRow({ remainingCount, onViewAll }: ViewAllDataRowProps) {
321314
</div>
322315
<span className="self-start text-indigo-500">View all</span>
323316
</div>
324-
</div>
317+
</button>
325318
);
326319
}
327320

apps/webapp/app/components/runs/v3/RunFilters.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ function MainMenu({ searchValue, trigger, clearSearchValue, setFilterType }: Men
546546
{filtered.map((type, index) => (
547547
<SelectButtonItem
548548
key={type.name}
549+
accessibleLabel={type.title}
549550
onClick={() => {
550551
clearSearchValue();
551552
setFilterType(type.name);

apps/webapp/app/components/sessions/v1/SessionFilters.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ function MainMenu({ searchValue, trigger, clearSearchValue, setFilterType }: Men
236236
{filtered.map((type, index) => (
237237
<SelectButtonItem
238238
key={type.name}
239+
accessibleLabel={type.title}
239240
onClick={() => {
240241
clearSearchValue();
241242
setFilterType(type.name);

apps/webapp/app/components/webhookDeliveries/v1/WebhookDeliveryFilters.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ function MainMenu({ trigger, clearSearchValue, setFilterType }: MenuProps) {
165165
{filterTypes.map((type, index) => (
166166
<SelectButtonItem
167167
key={type.name}
168+
accessibleLabel={type.title}
168169
onClick={() => {
169170
clearSearchValue();
170171
setFilterType(type.name);

apps/webapp/app/routes/storybook.filter/route.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ function MainMenu({ searchValue, clearSearchValue, setFilterType, trigger, short
124124
{filtered.map((type, index) => (
125125
<SelectButtonItem
126126
key={type.name}
127+
accessibleLabel={type.title}
127128
onClick={() => {
128129
clearSearchValue();
129130
setFilterType(type.name);

0 commit comments

Comments
 (0)