sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

fix: Add "skip to main content" a11y feature

Open kaycebasques opened this issue 1 year ago • 6 comments

Subject: Improve usability of core Sphinx themes for people who rely on Tab-based navigation

Feature or Bugfix

  • Bugfix

Purpose

  • Improve the accessibility of core Sphinx themes

Relates

  • #12407 12407

kaycebasques avatar Jun 03 '24 22:06 kaycebasques

Hi @chrisjsewell picking this back up. I addressed your first round of comments. LMK if you want to proceed with this and I will add the same a11y fix/feature to all the other builtin themes.

kaycebasques avatar Jun 24 '24 18:06 kaycebasques

Hey @kaycebasques, thanks for pushing this forward. I left a question as the choice of the target seemed a tad unusual to me.

For reference, in PyData Sphinx theme, we use the main landmark as the target directly: https://github.com/pydata/pydata-sphinx-theme/blob/0d0154b30bc29ad96bb28bc5c8ae88fe7b00177d/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html#L39

Also, in the same line linked above, you will see that we use a d-print-none class in the skip-link itself. I think you should add this here, too. Otherwise, the Skip to main content button will show when users print stuff.

trallard avatar Jul 11 '24 16:07 trallard

OK, I've got this working with all built-in themes. See the attached screencast for verification.

verify.webm

kaycebasques avatar Jul 22 '24 23:07 kaycebasques

@trallard thanks for the review, I updated the feature to jump directly to the main content container and made sure that the "skip to main content" node does not leak through when printing

kaycebasques avatar Jul 22 '24 23:07 kaycebasques

hi @chrisjsewell this should be good to go now

kaycebasques avatar Jul 22 '24 23:07 kaycebasques

@kaycebasques I was trying to check the tab order (building the documentation first) and it seems the skiplink is not working.

When inspecting the source I can the main id seems to be missing from <div class="body" role="main"> Further inspecting the outline of the webpage confirms the main target element is missing (see screenshot attached)

Sphinx_—Sphinx_documentation-_Polypane

Is this something you are also seeing on your end?

Note I am only starting to familiarise with sphinx codebase so it is likely I am missing something on how layout/styles/themes relate to each other so thought I would check first.

trallard avatar Jul 31 '24 15:07 trallard