React fix

Before and after

Broken — before
// Broken React dropdown: bare <select> with no <label> or aria-label
export function SortSelect({ value, onChange }: { value: string; onChange: (v: string) => void }) {
  return (
    <select value={value} onChange={(e) => onChange(e.target.value)}>
      <option value="impact">Sort by impact</option>
      <option value="pages">Sort by affected pages</option>
    </select>
  );
}
Fixed — after
// Fixed React SelectField: useId() binds <label htmlFor> to <select id>
import { useId } from "react";

interface SelectOption {
  value: string;
  label: string;
}

interface SelectFieldProps {
  label: string;
  value: string;
  options: readonly SelectOption[];
  onChange: (value: string) => void;
}

export function SelectField({ label, value, options, onChange }: SelectFieldProps) {
  const selectId = useId();
  return (
    <div className="select-field">
      <label htmlFor={selectId}>{label}</label>
      <select id={selectId} value={value} onChange={(e) => onChange(e.target.value)}>
        {options.map((opt) => (
          <option key={opt.value} value={opt.value}>
            {opt.label}
          </option>
        ))}
      </select>
    </div>
  );
}
Live preview

Fixed vs. broken example

Passes select-name
Accessibility tree: role="combobox", accessible name="Sort products by", value="Featured"

Avoid relying on a dummy first <option> like "Sort by..." as the sole label; once a user picks an option, the purpose disappears for everyone.

Automated test

Playwright + axe-core check

tests/a11y-select-name.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("React filter and sort <select> controls pass select-name", async ({ page }) => {
  await page.goto("/dashboard/clusters");
  await expect(page.getByRole("combobox", { name: "Sort clusters by" })).toBeVisible();
  const results = await new AxeBuilder({ page })
    .withRules(["select-name"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

Fixing one shared <SelectField /> or <TablePageSizeSelect /> component resolves select-name clusters across every table, report, and catalog view in your React application.

Screen readers

What NVDA and VoiceOver announce

E-commerce variant pickers (Size, Color), collection sort dropdowns, and country selectors without a programmatic <label> or aria-label announce only the first option ('Featured' or 'Small'), hiding what the dropdown controls.

NVDA (Windows)

Broken

"combo box, Featured, collapsed" (purpose of selector unknown)


Fixed

"Sort products by, combo box, Featured, collapsed"

VoiceOver (macOS / iOS)

Broken

"Featured, pop-up button"


Fixed

"Sort products by, Featured, pop-up button"

Common questions

When is aria-label acceptable instead of a visible <label> on a React <select>?
Use a visible <label htmlFor> whenever space permits (especially in forms). For ultra-compact table toolbars (like 'Rows per page'), either a visually-hidden <label> or aria-label passes select-name.
Why does Playwright query <select> with getByRole('combobox')?
Single-select native <select> elements expose the ARIA role 'combobox' (whereas <select multiple> exposes 'listbox'). Asserting getByRole('combobox', { name: '...' }) verifies the exact accessible name.
Should a React <select> auto-navigate immediately onChange?
On keyboard browsers, pressing Down Arrow fires onChange immediately on some platforms; updating in-place filters/sorting is fine if focus stays stable, whereas full page navigations should wait for explicit activation.