From 358aaae1656125583dcbe768d9edaccd8f8655f3 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 12 Mar 2024 21:54:00 +0000 Subject: [PATCH] fix(a11y): DocSidebarItemCategory expand/collapsed button --- .../src/theme/DocSidebarItem/Category/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx index 8890a8043d2b..06dad7c76a32 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx @@ -101,6 +101,7 @@ function CollapseButton({ {label: categoryLabel}, ) } + aria-expanded={!collapsed} type="button" className="clean-btn menu__caret" onClick={onClick} @@ -193,7 +194,8 @@ export default function DocSidebarItemCategory({ } } aria-current={isCurrentPage ? 'page' : undefined} - aria-expanded={collapsible ? !collapsed : undefined} + role={collapsible && !href ? 'button' : undefined} + aria-expanded={collapsible && !href ? !collapsed : undefined} href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback} {...props}> {label}