Dostępność
a11y/table-sort
Sortable columns use a button inside the th, and aria-sort only on the header of the column that is sorted.
umiarkowanaręczneWCAG 2.1.1, 4.1.2 · Afe-a11y-tables
Dlaczego
A click handler on the <th> cannot be reached with the keyboard and does not say it can be activated. Without aria-sort nobody using a screen reader knows the current order.
Poprawka
Put <button type="button"> inside each sortable <th> with the column name as its text; set aria-sort="ascending" or "descending" on the sorted <th> only, and remove it from the others. Announce the new order in a polite live region if the table is long.
Przykłady
<th scope="col" aria-sort="ascending"><button type="button">Date <span aria-hidden="true">▲</span></button></th>
<th scope="col"><button type="button">Amount</button></th>Źródła
Fakty
- Identyfikator
a11y/table-sort- Waga
- umiarkowana
- Sprawdzanie
- ręczne ocenia człowiek; raport podaje to jako listę kontrolną
- Dotyczy plików
htmlangularvuesvelteastrojsx- WCAG 2.2
- 2.1.1, 4.1.2, poziom A
- Uczy jej skill
fe-a11y-tablesData tables- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain a11y/table-sort