Skip to content

Commit eecfdeb

Browse files
authored
fix(theme): add missing aria-labels to the main and sidebar navs (#8366)
Fix #8308
1 parent 7921467 commit eecfdeb

29 files changed

Lines changed: 68 additions & 0 deletions

packages/docusaurus-theme-classic/src/theme/DocSidebar/Desktop/Content/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
useAnnouncementBar,
1313
useScrollPosition,
1414
} from '@docusaurus/theme-common/internal';
15+
import {translate} from '@docusaurus/Translate';
1516
import DocSidebarItems from '@theme/DocSidebarItems';
1617
import type {Props} from '@theme/DocSidebar/Desktop/Content';
1718

@@ -41,6 +42,11 @@ export default function DocSidebarDesktopContent({
4142

4243
return (
4344
<nav
45+
aria-label={translate({
46+
id: 'theme.docs.sidebar.navAriaLabel',
47+
message: 'Docs sidebar',
48+
description: 'The ARIA label for the sidebar navigation',
49+
})}
4450
className={clsx(
4551
'menu thin-scrollbar',
4652
styles.menu,

packages/docusaurus-theme-classic/src/theme/Navbar/Layout/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
useHideableNavbar,
1313
useNavbarMobileSidebar,
1414
} from '@docusaurus/theme-common/internal';
15+
import {translate} from '@docusaurus/Translate';
1516
import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
1617
import type {Props} from '@theme/Navbar/Layout';
1718

@@ -36,6 +37,11 @@ export default function NavbarLayout({children}: Props): JSX.Element {
3637
return (
3738
<nav
3839
ref={navbarRef}
40+
aria-label={translate({
41+
id: 'theme.NavBar.navAriaLabel',
42+
message: 'Main',
43+
description: 'The ARIA label for the main navigation',
44+
})}
3945
className={clsx(
4046
'navbar',
4147
'navbar--fixed-top',

packages/docusaurus-theme-translations/locales/ar/theme-common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "تبديل فئة الشريط الجاني القابل للاغلاق '{label}'",
99
"theme.ErrorPageContent.title": "هذه الصفحة لا تستجيب.",
1010
"theme.ErrorPageContent.tryAgain": "المحاولة مجددا",
11+
"theme.NavBar.navAriaLabel": "Main",
1112
"theme.NotFound.p1": "لم نتمكن من العثور على ما كنت تبحث عنه.",
1213
"theme.NotFound.p2": "يرجى الاتصال بمالك الموقع الذي ربطك بعنوان URL الأصلي وإخباره بأن الارتباط الخاص به معطل.",
1314
"theme.NotFound.title": "الصفحة غير موجودة",
@@ -48,6 +49,7 @@
4849
"theme.docs.sidebar.collapseButtonTitle": "طي الشريط الجانبي",
4950
"theme.docs.sidebar.expandButtonAriaLabel": "توسيع الشريط الجانبي",
5051
"theme.docs.sidebar.expandButtonTitle": "توسيع الشريط الجانبي",
52+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
5153
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
5254
"theme.docs.tagDocListPageTitle": "{nDocsTagged} مستند موسوم بـ \"{tagName}\"",
5355
"theme.docs.tagDocListPageTitle.nDocsTagged": "مستند موسوم واحد|{count} مستندات موسومة",

packages/docusaurus-theme-translations/locales/base/theme-common.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"theme.ErrorPageContent.title___DESCRIPTION": "The title of the fallback page when the page crashed",
1818
"theme.ErrorPageContent.tryAgain": "Try again",
1919
"theme.ErrorPageContent.tryAgain___DESCRIPTION": "The label of the button to try again rendering when the React error boundary captures an error",
20+
"theme.NavBar.navAriaLabel": "Main",
21+
"theme.NavBar.navAriaLabel___DESCRIPTION": "The ARIA label for the main navigation",
2022
"theme.NotFound.p1": "We could not find what you were looking for.",
2123
"theme.NotFound.p1___DESCRIPTION": "The first paragraph of the 404 page",
2224
"theme.NotFound.p2": "Please contact the owner of the site that linked you to the original URL and let them know their link is broken.",
@@ -97,6 +99,8 @@
9799
"theme.docs.sidebar.expandButtonAriaLabel___DESCRIPTION": "The ARIA label and title attribute for expand button of doc sidebar",
98100
"theme.docs.sidebar.expandButtonTitle": "Expand sidebar",
99101
"theme.docs.sidebar.expandButtonTitle___DESCRIPTION": "The ARIA label and title attribute for expand button of doc sidebar",
102+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
103+
"theme.docs.sidebar.navAriaLabel___DESCRIPTION": "The ARIA label for the sidebar navigation",
100104
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
101105
"theme.docs.sidebar.toggleSidebarButtonAriaLabel___DESCRIPTION": "The ARIA label for hamburger menu button of mobile navigation",
102106
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",

packages/docusaurus-theme-translations/locales/bn/theme-common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "Toggle the collapsible sidebar category '{label}'",
99
"theme.ErrorPageContent.title": "This page crashed.",
1010
"theme.ErrorPageContent.tryAgain": "Try again",
11+
"theme.NavBar.navAriaLabel": "Main",
1112
"theme.NotFound.p1": "আপনি যা খুঁজছিলেন তা আমরা খুঁজে পাইনি।",
1213
"theme.NotFound.p2": "দয়া করে সাইটের মালিকের সাথে যোগাযোগ করুন যা আপনাকে মূল URL এর সাথে যুক্ত করেছে এবং তাদের লিঙ্কটি ভাঙ্গা রয়েছে তা তাদের জানান।",
1314
"theme.NotFound.title": "পেজটি খুঁজে পাওয়া যায়নি",
@@ -48,6 +49,7 @@
4849
"theme.docs.sidebar.collapseButtonTitle": "সাইডবারটি সঙ্কুচিত করুন",
4950
"theme.docs.sidebar.expandButtonAriaLabel": "সাইডবারটি প্রসারিত করুন",
5051
"theme.docs.sidebar.expandButtonTitle": "সাইডবারটি প্রসারিত করুন",
52+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
5153
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
5254
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
5355
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",

packages/docusaurus-theme-translations/locales/cs/theme-common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "Toggle the collapsible sidebar category '{label}'",
99
"theme.ErrorPageContent.title": "This page crashed.",
1010
"theme.ErrorPageContent.tryAgain": "Try again",
11+
"theme.NavBar.navAriaLabel": "Main",
1112
"theme.NotFound.p1": "Nepodařilo se nám najít co jste hledal(a).",
1213
"theme.NotFound.p2": "Kontaktujte prosím vlastníka webu, který vás odkázal na původní URL a upozorněte ho, že jejich odkaz nefunguje.",
1314
"theme.NotFound.title": "Stránka nenalezena",
@@ -48,6 +49,7 @@
4849
"theme.docs.sidebar.collapseButtonTitle": "Zavřít postranní lištu",
4950
"theme.docs.sidebar.expandButtonAriaLabel": "Otevřít postranní lištu",
5051
"theme.docs.sidebar.expandButtonTitle": "Otevřít postranní lištu",
52+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
5153
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
5254
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
5355
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",

packages/docusaurus-theme-translations/locales/da/theme-common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "Toggle the collapsible sidebar category '{label}'",
99
"theme.ErrorPageContent.title": "This page crashed.",
1010
"theme.ErrorPageContent.tryAgain": "Try again",
11+
"theme.NavBar.navAriaLabel": "Main",
1112
"theme.NotFound.p1": "Vi kunne ikke finde det, du søgte.",
1213
"theme.NotFound.p2": "Venligst kontakt ejeren til webstedet, som førte dig frem denne URL, og informer dem om at linket ikke virker.",
1314
"theme.NotFound.title": "Siden blev ikke fundet",
@@ -48,6 +49,7 @@
4849
"theme.docs.sidebar.collapseButtonTitle": "Sammenlæg sidenavigation",
4950
"theme.docs.sidebar.expandButtonAriaLabel": "Udvid sidenavigation",
5051
"theme.docs.sidebar.expandButtonTitle": "Udvid sidenavigation",
52+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
5153
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
5254
"theme.docs.tagDocListPageTitle": "{nDocsTagged} with \"{tagName}\"",
5355
"theme.docs.tagDocListPageTitle.nDocsTagged": "One doc tagged|{count} docs tagged",

packages/docusaurus-theme-translations/locales/de/theme-common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "Umschalten der Seitenleiste mit einklappbarer Kategorie '{label}'",
99
"theme.ErrorPageContent.title": "Die Seite ist abgestürzt.",
1010
"theme.ErrorPageContent.tryAgain": "Nochmal versuchen",
11+
"theme.NavBar.navAriaLabel": "Main",
1112
"theme.NotFound.p1": "Wir konnten nicht finden, wonach Sie gesucht haben.",
1213
"theme.NotFound.p2": "Bitte kontaktieren Sie den Besitzer der Seite, die Sie mit der ursprünglichen URL verlinkt hat, und teilen Sie ihm mit, dass der Link nicht mehr funktioniert.",
1314
"theme.NotFound.title": "Seite nicht gefunden",
@@ -48,6 +49,7 @@
4849
"theme.docs.sidebar.collapseButtonTitle": "Seitenleiste einklappen",
4950
"theme.docs.sidebar.expandButtonAriaLabel": "Seitenleiste ausklappen",
5051
"theme.docs.sidebar.expandButtonTitle": "Seitenleiste ausklappen",
52+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
5153
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
5254
"theme.docs.tagDocListPageTitle": "{nDocsTagged} mit \"{tagName}\"",
5355
"theme.docs.tagDocListPageTitle.nDocsTagged": "Ein doc getaggt|{count} docs getaggt",

packages/docusaurus-theme-translations/locales/es/theme-common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "Toggle the collapsible sidebar category '{label}'",
99
"theme.ErrorPageContent.title": "This page crashed.",
1010
"theme.ErrorPageContent.tryAgain": "Try again",
11+
"theme.NavBar.navAriaLabel": "Main",
1112
"theme.NotFound.p1": "No pudimos encontrar lo que buscaba.",
1213
"theme.NotFound.p2": "Comuníquese con el dueño del sitio que lo vinculó a la URL original y hágale saber que su vínculo está roto.",
1314
"theme.NotFound.title": "Página No Encontrada",
@@ -48,6 +49,7 @@
4849
"theme.docs.sidebar.collapseButtonTitle": "Colapsar barra lateral",
4950
"theme.docs.sidebar.expandButtonAriaLabel": "Expandir barra lateral",
5051
"theme.docs.sidebar.expandButtonTitle": "Expandir barra lateral",
52+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
5153
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
5254
"theme.docs.tagDocListPageTitle": "{nDocsTagged} con \"{tagName}\"",
5355
"theme.docs.tagDocListPageTitle.nDocsTagged": "Un documento etiquetado|{count} documentos etiquetados",

packages/docusaurus-theme-translations/locales/fa/theme-common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "دسته‌بندی برچسب '{label}' در نوار کناری را تغییر دهید ",
99
"theme.ErrorPageContent.title": "بارگذاری صفحه با خطا روبرو شد.",
1010
"theme.ErrorPageContent.tryAgain": "تلاش مجدد",
11+
"theme.NavBar.navAriaLabel": "Main",
1112
"theme.NotFound.p1": "صفحه‌ای که دنبال آن بودید پیدا نشد.",
1213
"theme.NotFound.p2": "لطفا با صاحب وبسایت تماس بگیرید و ایشان را از مشکل پیش آمده مطلع کنید.",
1314
"theme.NotFound.title": "صفحه ای که دنبال آن بودید پیدا نشد.",
@@ -48,6 +49,7 @@
4849
"theme.docs.sidebar.collapseButtonTitle": "بستن نوار کناری",
4950
"theme.docs.sidebar.expandButtonAriaLabel": "باز کردن نوار کناری",
5051
"theme.docs.sidebar.expandButtonTitle": "باز کردن نوار کناری",
52+
"theme.docs.sidebar.navAriaLabel": "Docs sidebar",
5153
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": "Toggle navigation bar",
5254
"theme.docs.tagDocListPageTitle": "{nDocsTagged} با \"{tagName}\"",
5355
"theme.docs.tagDocListPageTitle.nDocsTagged": "یک مطلب برچسب شده|{count} مطلب برچسب شده",

0 commit comments

Comments
 (0)