Dostępność

a11y/combobox-on-input

role="combobox" sits on the input itself (ARIA 1.2), not on a wrapper element that contains the input.

poważnastatyczneWCAG 4.1.2 · Afe-a11y-combobox

Dlaczego

The wrapper shape comes from older ARIA versions. Current screen readers expect the focused input to be the combobox; with the role on a div they announce a plain edit field and never say that suggestions exist or which one is highlighted.

Poprawka

Put role="combobox", aria-expanded, aria-controls (the listbox id) and aria-autocomplete on the <input>, keep its <label>, and drop the wrapper's role and aria-owns. A select-only combobox (no typing) puts the role on a focusable div or button and has no input.

Przykłady

<!-- bad -->
<div role="combobox" aria-expanded="false"><input type="text"></div>
<!-- good -->
<input type="text" role="combobox" aria-expanded="false" aria-controls="list" aria-autocomplete="list">

Źródła

Fakty

Identyfikator
a11y/combobox-on-input
Waga
poważna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
html angular vue svelte astro jsx
WCAG 2.2
4.1.2, poziom A
Ten sam problem w
axe-core aria-required-children
Uczy jej skill
fe-a11y-combobox Combobox, listbox and custom select
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain a11y/combobox-on-input