fix(theme): improve a11y of DocSidebarItemCategory expand/collapsed button (#9944)

This commit is contained in:
Max Schmitt 2024-03-14 14:59:36 +01:00 committed by GitHub
parent 6151a41428
commit 032e3b8f4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -101,6 +101,7 @@ function CollapseButton({
{label: categoryLabel}, {label: categoryLabel},
) )
} }
aria-expanded={!collapsed}
type="button" type="button"
className="clean-btn menu__caret" className="clean-btn menu__caret"
onClick={onClick} onClick={onClick}
@ -193,7 +194,8 @@ export default function DocSidebarItemCategory({
} }
} }
aria-current={isCurrentPage ? 'page' : undefined} 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} href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
{...props}> {...props}>
{label} {label}