From aae6a82e558027e9d6073e77f1ec20226f6deb48 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 12 Mar 2024 20:50:59 +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 8890a8043d2b8..c42de4e093f57 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,8 +194,9 @@ export default function DocSidebarItemCategory({ } } aria-current={isCurrentPage ? 'page' : undefined} - aria-expanded={collapsible ? !collapsed : undefined} href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback} + aria-expanded={collapsible && !href ? !collapsed : undefined} + role={collapsible && !href ? 'button' : undefined} {...props}> {label}