Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a11y support for tabindex="0" to make scrollable pre focusable #514

Closed
rhymes opened this issue May 23, 2021 · 2 comments · Fixed by #515
Closed

Add a11y support for tabindex="0" to make scrollable pre focusable #514

rhymes opened this issue May 23, 2021 · 2 comments · Fixed by #515

Comments

@rhymes
Copy link
Contributor

rhymes commented May 23, 2021

What problem does this feature solve?

Currently the generated <pre> element isn't fully accessible as it can't be focused by keyboard users.

An example of syntax highlighting (using Hugo) and how the aXe devTools extension detects this issue:

Screenshot 2021-05-23 at 10 35 27 PM

Additional info:

The key to getting a scrollable region to be accessible with the keyboard is to ensure that a keyboard-only user can focus the scrollable region itself or a static text item within the scrollable region.

Thus, scrollable content is keyboard accessible only if the scrollable element is focusable or contains a focusable element.

What feature do you propose?

To make this fully accessible, the attribute tabindex="0" should be added to the <pre> tag.

According to MDN's page on tabindex the attribute can have 3 values:

  • -1, which means "skip it using sequential tabbing"
  • 0, focusable with sequential keyboard navigation (what we want in this case)
  • something over 0, which changes the priority of tabbing inside the page
@alecthomas
Copy link
Owner

Sounds reasonable, PR welcome.

@rhymes
Copy link
Contributor Author

rhymes commented May 23, 2021

@alecthomas thanks! Done: #515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants