Dostępność

a11y/positive-tabindex

No element has a tabindex greater than 0; focus order follows the source order.

poważnastatyczneWCAG 2.4.3 · Afe-a11y-keyboard

Dlaczego

A positive tabindex moves the element ahead of everything else in the Tab order, so keyboard users jump around the page in an order that no longer matches what they see.

Poprawka

Use tabindex="0" to make a custom control focusable in source order and tabindex="-1" for something focused only by script. Change the order by changing the DOM order, not tabindex.

Przykłady

<!-- bad -->
<button tabindex="3">Save</button>
<!-- good -->
<button>Save</button>

Źródła

Fakty

Identyfikator
a11y/positive-tabindex
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
2.4.3, poziom A
Ten sam problem w
axe-core tabindex
Uczy jej skill
fe-a11y-keyboard Keyboard access and focus
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain a11y/positive-tabindex