-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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(theme): add aria-label to skip to content link region #7982
Conversation
@@ -14,7 +14,7 @@ import styles from './styles.module.css'; | |||
export default function SkipToContent(): JSX.Element { | |||
const {containerRef, handleSkip} = useSkipToContent(); | |||
return ( | |||
<div ref={containerRef} role="region"> | |||
<div ref={containerRef} role="region" aria-label="Skip to main content"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a translation? It would share the same key as the main content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed
div role="region"
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
<div ref={containerRef} role="region" aria-label={<Translate | ||
id="theme.common.skipToMainContentAriaLabel" | ||
description="The skip to content aria label used for accessibility of the region div "> | ||
Skip to main content | ||
</Translate>}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use translate
. JSX elements are objects, not strings. You can check the other aria-label
s:
docusaurus/packages/docusaurus-theme-classic/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx
Lines 25 to 29 in 94067ce
aria-label={translate({ | |
id: 'theme.docs.sidebar.collapseButtonAriaLabel', | |
message: 'Collapse sidebar', | |
description: 'The title attribute for collapse button of doc sidebar', | |
})} |
It also needs to be formatted. If you don't want to check this out locally and run format, I can do that for you later.
Also, no need to add another id
; just reuse the exact same thing from the <Translate>
element. translate({ id: "theme.common.skipToMainContent" })
should be sufficient already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. Thanks for the help. I'm not really a JS pro...
Okay, it's good from my side. I would check this out locally and if it works as expected we can merge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
fixes #7981
Pre-flight checklist
Motivation
Test Plan
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs