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

fix: improve sidebar accessibility structure (#8429) #11038

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LassadBoubarma
Copy link

This PR addresses issue #8429 by improving the accessibility structure of the documentation sidebar.

Changes Made:

  • Replaced the outer <div>/<aside> with a semantic <nav aria-label="docs sidebar">
  • Applied aria-hidden="true" to the logo when not intended to be focusable or read
  • Cleaned up markup to match accessibility expectations

#Why this is still useful:

Although NVDA did not read the logo before the fix, the original markup was semantically incorrect:

  • The outer <aside> was unnecessary and could cause duplicate landmark announcements in some screen readers
  • The logo lacked explicit aria-hidden, leaving its behaviour inconsistent across assistive tech

This change makes the sidebar:

  • More semantically correct
  • More predictable across screen readers
  • Closer to WAI-ARIA and a11y best practices

Tested locally with NVDA and DOM inspection.

@facebook-github-bot
Copy link
Contributor

Hi @LassadBoubarma!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 70 🟢 98 🟢 100 🟢 100 Report
/docs/installation 🟠 50 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 71 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 63 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 62 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 63 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 73 🟢 100 🟢 100 🟠 86 Report

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 28, 2025
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

We can consider this change but the PR is currently not in a state I can merge, and includes totally unrelated changes.


I don't see where you replaced <aside>

  • Applied aria-hidden="true" to the logo when not intended to be focusable or read

IMHO it shouldn't always be applied, there are cases where the logo should be focusable

  • Cleaned up markup to match accessibility expectations

What do you mean exactly?

#Why this is still useful:

Although NVDA did not read the logo before the fix, the original markup was semantically incorrect:

  • The outer <aside> was unnecessary and could cause duplicate landmark announcements in some screen readers

Which <aside>, which screen readers and what do each of them read?

After your fix, what do these screen readers read?

)}
aria-label="docs sidebar">
{hideOnScroll && (
<Logo tabIndex={-1} className={styles.sidebarLogo} aria-hidden="true" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, the aria-hidden="true" shouldn't always be applied.

When the site navbar is shown, then that logo is behind the navbar so it's hidden:

CleanShot 2025-03-28 at 10 16 14

However when the site gets scrolled and the navbar disappears, this logo becomes visible, and is an actual link to the site homepage. In this case I don't believe applying aria-hidden is a good idea

CleanShot 2025-03-28 at 10 16 50

)}>
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
)}
aria-label="docs sidebar">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All our Aria labels should use our translation framework so that they can be localized

// We also clear website/build dir
// returns void, no useful result needed before compilation
// See also https://github.com/facebook/docusaurus/pull/11037
clearPath(outDir),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to accessibility, please remove all the unwanted changes from this PR diff

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for your feedback and sorry for the late response !

I will just clarify this points :

About the <aside> replacement:
You're totally right — I didn’t actually replace an <aside> in the current markup. What I meant was that I replaced a generic container (previously a <div> or <aside> depending on the context) with a more semantic <nav aria-label="docs sidebar">. Sorry for the confusion there

Regarding aria-hidden="true" on the logo:
Good catch. I see your point now, applying aria-hidden unconditionally isn't ideal. The logo is indeed visible and interactive when the navbar scrolls away, so hiding it at that point isn’t great for accessibility.

Screen reader testing:
I tested with NVDA on Windows. Before the change, the logo was inconsistently handled, and the outer <aside> (when present) sometimes caused duplicate landmarks to be announced.

Translation of aria-label:
Thanks for pointing that out

Unrelated changes:
You're absolutely right — the change to buildLocale.ts doesn't belong in this PR.

Appreciate the thoughtful review!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

Let me know if you plan to improve the PR to meet the requirements

@slorber slorber added the domain: a11y Related to accessibility concerns of the default theme label Mar 28, 2025
@slorber slorber marked this pull request as draft April 10, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA domain: a11y Related to accessibility concerns of the default theme
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants