-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
IconExternalLink, give aria-label "opens in new tab" #11331
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
base: main
Are you sure you want to change the base?
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Here's a (untested) patch with an alternate approach if desired. It doesn't seem bad to me that NVDA announces that there's visually a "graphic" there, but a diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx
index a39b85a..9ce4c77 100644
--- a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Link/index.tsx
@@ -52,7 +52,12 @@ export default function DocSidebarItemLink({
})}
{...props}>
{label}
- {!isInternalLink && <IconExternalLink />}
+ {!isInternalLink && (
+ <>
+ <span className="screen-reader-only"> (opens in new tab)</span>
+ <IconExternalLink />
+ </>
+ )}
</Link>
</li>
);
diff --git a/packages/docusaurus-theme-classic/src/theme/Footer/LinkItem/index.tsx b/packages/docusaurus-theme-classic/src/theme/Footer/LinkItem/index.tsx
index ac4f6b4..92b5fbc 100644
--- a/packages/docusaurus-theme-classic/src/theme/Footer/LinkItem/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/Footer/LinkItem/index.tsx
@@ -30,7 +30,12 @@ export default function FooterLinkItem({item}: Props): ReactNode {
})}
{...props}>
{label}
- {href && !isInternalUrl(href) && <IconExternalLink />}
+ {href && !isInternalUrl(href) && (
+ <>
+ <span className="screen-reader-only"> (opens in new tab)</span>
+ <IconExternalLink />
+ </>
+ )}
</Link>
);
}
diff --git a/packages/docusaurus-theme-classic/src/theme/Icon/ExternalLink/index.tsx b/packages/docusaurus-theme-classic/src/theme/Icon/ExternalLink/index.tsx
index 7b104df..87523b6 100644
--- a/packages/docusaurus-theme-classic/src/theme/Icon/ExternalLink/index.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/Icon/ExternalLink/index.tsx
@@ -22,7 +22,7 @@ export default function IconExternalLink({
<svg
width={width}
height={height}
- aria-label="(opens in new tab)"
+ aria-hidden="true"
className={styles.iconExternalLink}>
<use href={svgSprite} />
</svg>
diff --git a/packages/docusaurus-theme-classic/src/theme/NavbarItem/NavbarNavLink.tsx b/packages/docusaurus-theme-classic/src/theme/NavbarItem/NavbarNavLink.tsx
index 52e198d..016893b 100644
--- a/packages/docusaurus-theme-classic/src/theme/NavbarItem/NavbarNavLink.tsx
+++ b/packages/docusaurus-theme-classic/src/theme/NavbarItem/NavbarNavLink.tsx
@@ -39,9 +39,12 @@ export default function NavbarNavLink({
<>
{label}
{isExternalLink && (
- <IconExternalLink
- {...(isDropdownLink && {width: 12, height: 12})}
- />
+ <>
+ <span className="screen-reader-only"> (opens in new tab)</span>
+ <IconExternalLink
+ {...(isDropdownLink && {width: 12, height: 12})}
+ />
+ </>
)}
</>
), |
Pre-flight checklist
[ ] If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.Motivation
Test Plan
Before/after behavior with NVDA:
assistivlabs_win-nvda_2025.1.1_win-chrome_137_2025-07-16T17-55-57.258Z.mp4
Test links
Deploy preview: https://deploy-preview-11331--docusaurus-2.netlify.app/