Skip to content

Conversation

@r-lawrence
Copy link
Contributor

@r-lawrence r-lawrence commented Nov 24, 2022

Pre-flight checklist

I did not add any tests. The PR is too add an aria-label to the main/sidebar nav's. I visually verified the arial-label was populating correctly on the sidebars and also noticed tests for the translate function located at packages/docusaurus/src/client/exports/__tests__/Translate.test.tsx

Motivation

Looking to make some open source contributions to this repository. I noticed bug Issue #8308 and figured I would take a stab at it.

This PR adds an aria-label attribute to navigation bars found on https://docusaurus.io/docs allowing assistive technologies like screen readers to identify unique navigation elements.

Test Plan

verify the problem:

  1. navigate to https://docusaurus.io/docs
  2. open your browser developer tools and search for <nav> and verify the first and second nav elements do not contain an aria-label attribute.

verify the fix:

  1. download this branch to your local
  2. checkout this branch and run npm run start
  3. once the application has loaded, navigate to http://localhost:3000/docs, and open your browser inspection tools
  4. search the html for <nav>
  5. verify the first nav element has an aria-label="Main"
  6. verify the second nav element has an aria-label="Docs sidebar"

before:

main nav:
image

sidebar nav:
image

after:

main nav:
image

sidebar nav:
image

Test links

Deploy preview: https://deploy-preview-8366--docusaurus-2.netlify.app/

Related issues/PRs

Fix #8308

@facebook-github-bot
Copy link
Contributor

Hi @r-lawrence!

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!

@netlify
Copy link

netlify bot commented Nov 24, 2022

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 7349b76
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6381230dd2c49f000832771e
😎 Deploy Preview https://deploy-preview-8366--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Nov 24, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟢 90 🟢 97 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 84 🟢 100 🟢 100 🟢 100 🟢 90 Report

@r-lawrence r-lawrence force-pushed the adds_arial-label_to_main/sidebar_nav branch from d9698f1 to a4acfd1 Compare November 24, 2022 04:46
@r-lawrence r-lawrence mentioned this pull request Nov 24, 2022
7 tasks
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 24, 2022
@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!

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, that's a good start 👍

As the unit test says, you have to run yarn workspace @docusaurus/theme-translations update once ids/labels are good, so that we can merge the PRs. This updates all our default translation files and make the test pass

const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
const ariaLabel = translate({
id: 'theme.NavBar.mainAriaLabel',
message: 'Main',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again @Alena5041 is this "Main" label precise enough?

I'm not an expert in screen readers but what will they announce, and will their users understand what this nav is about?

Choose a reason for hiding this comment

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

Yes, it’s enough in this case.

@r-lawrence
Copy link
Contributor Author

r-lawrence commented Nov 25, 2022

Thanks, that's a good start 👍

As the unit test says, you have to run yarn workspace @docusaurus/theme-translations update once ids/labels are good, so that we can merge the PRs. This updates all our default translation files and make the test pass

Thanks for all the feedback and information. I'll be working today to update the PR accordingly.

update: all changes have been made, translations have been updated with yarn workspace @docusaurus/theme-translations update (tyvm for command), and PR is ready to be reviewed again. Let me know if anything else needs to be changed. Thanks a bunch!

@r-lawrence r-lawrence force-pushed the adds_arial-label_to_main/sidebar_nav branch from a4acfd1 to 800cf93 Compare November 25, 2022 19:51
@r-lawrence r-lawrence marked this pull request as ready for review November 25, 2022 20:02
@r-lawrence r-lawrence requested review from Alena5041 and slorber and removed request for Alena5041 and slorber November 25, 2022 20:03
@r-lawrence r-lawrence force-pushed the adds_arial-label_to_main/sidebar_nav branch from 800cf93 to 213181d Compare November 25, 2022 20:11
@r-lawrence r-lawrence force-pushed the adds_arial-label_to_main/sidebar_nav branch from 213181d to 7349b76 Compare November 25, 2022 20:18
@slorber slorber changed the title bug: adds an aria-label to the main and sidebar navs fix(theme): adds aria-label to the main and sidebar navs Nov 30, 2022
@slorber slorber changed the title fix(theme): adds aria-label to the main and sidebar navs fix(theme): add missing aria-labels to the main and sidebar navs Nov 30, 2022
@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Nov 30, 2022
@slorber
Copy link
Collaborator

slorber commented Nov 30, 2022

LGTM thanks

Fix #8308

@slorber slorber merged commit eecfdeb into facebook:main Nov 30, 2022
@slorber slorber added the to backport This PR is planned to be backported to a stable version of Docusaurus label Jan 26, 2023
@slorber slorber added backported This PR has been backported to a stable version of Docusaurus and removed to backport This PR is planned to be backported to a stable version of Docusaurus labels Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported This PR has been backported to a stable version of Docusaurus CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing aria-label in nav

4 participants