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

markup: Add tabindex="0" to default <pre> wrapper. #8568

Merged
merged 1 commit into from
Jul 15, 2021
Merged

markup: Add tabindex="0" to default <pre> wrapper. #8568

merged 1 commit into from
Jul 15, 2021

Conversation

rhymes
Copy link
Contributor

@rhymes rhymes commented May 23, 2021

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

An example of syntax highlighting 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.

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

Closes #7194

See also alecthomas/chroma#514

Currently the generated `<pre>` element isn't fully accessible as it can't be focused by keyboard users.
To make this fully accessible, the attribute `tabindex="0"` should be added to the `<pre>` tag.

Closes #7194
@CLAassistant
Copy link

CLAassistant commented May 23, 2021

CLA assistant check
All committers have signed the CLA.

@rhymes rhymes marked this pull request as ready for review May 23, 2021 22:15
@bep bep merged commit f27e542 into gohugoio:master Jul 15, 2021
@rhymes rhymes deleted the rhymes/highlight-tabindex-0 branch July 15, 2021 14:52
@chrisreddington
Copy link

Thank you @rhymes for doing the work on this! I recently encountered the issue on my own site and raised the issue in #8758, so I'm glad to see this merged by @bep so quickly. Great to be a part of this awesome community - Thank you all!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tabindex to highlight template func markup
4 participants