fix(theme): Add aria-label to IconExternalLink with value '(opens in new tab)'#11331
Merged
slorber merged 3 commits intofacebook:mainfrom Jul 28, 2025
Merged
fix(theme): Add aria-label to IconExternalLink with value '(opens in new tab)'#11331slorber merged 3 commits intofacebook:mainfrom
aria-label to IconExternalLink with value '(opens in new tab)'#11331slorber merged 3 commits intofacebook:mainfrom
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Contributor
Author
|
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})}
+ />
+ </>
)}
</>
), |
2 tasks
aria-label to IconExternalLink with value '(opens in new tab)'
aria-label to IconExternalLink with value '(opens in new tab)'aria-label to IconExternalLink with value '(opens in new tab)'
7 tasks
Collaborator
|
Thanks, I think the current approach looks fine, and we shouldn't need auto-translate since we'll provided translated labels built-in (once our community translate them) |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/