sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.4k stars 4.11k forks source link

A11y: add attribute hints for `role="tab"` and `role="tabpanel"` #13226

Open theetrain opened 5 days ago

theetrain commented 5 days ago

Describe the problem

It would be nice to have a11y hints when constructing a tabbed interface via role="tab" and role="tabpanel".

Describe the proposed solution

Complete example: https://svelte.dev/repl/cb3364c7b97842be901b42dd2d597fe5?version=4.2.19

Requirements to satisfy role="tab":

Requirements to satisfy role="tabpanel":

Reference: https://www.w3.org/WAI/ARIA/apg/patterns/tabs/

Importance

nice to have

fcrozatier commented 5 days ago

More precisely the tabpanel only needs tabindex="0" when it doesn't contain a focusable element:

When the tabpanel does not contain any focusable elements or the first element with content is not focusable, the tabpanel should set tabindex="0" to include it in the tab sequence of the page.

Also up/down arrows should move the focus to the previous/next tab if aria-orientation="vertical"