Skip to content

Commit

Permalink
fix(v2): disable tab focus on collapsed doc sidebar items (#2625)
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 authored Apr 19, 2020
1 parent 409f878 commit 2c4490a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/docusaurus-theme-classic/src/theme/DocSidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import styles from './styles.module.css';

const MOBILE_TOGGLE_SIZE = 24;

function DocSidebarItem({item, onItemClick, collapsible}) {
function DocSidebarItem({item, onItemClick, collapsible, ...props}) {
const {items, href, label, type} = item;
const [collapsed, setCollapsed] = useState(item.collapsed);
const [prevCollapsedProp, setPreviousCollapsedProp] = useState(null);
Expand Down Expand Up @@ -50,12 +50,14 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
'menu__link--active': collapsible && !item.collapsed,
})}
href="#!"
onClick={collapsible ? handleItemClick : undefined}>
onClick={collapsible ? handleItemClick : undefined}
{...props}>
{label}
</a>
<ul className="menu__list">
{items.map((childItem) => (
<DocSidebarItem
tabIndex={collapsed ? '-1' : '0'}
key={childItem.label}
item={childItem}
onItemClick={onItemClick}
Expand Down Expand Up @@ -84,7 +86,8 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
: {
target: '_blank',
rel: 'noreferrer noopener',
})}>
})}
{...props}>
{label}
</Link>
</li>
Expand Down Expand Up @@ -153,7 +156,11 @@ function DocSidebar(props) {
return (
<div className={styles.sidebar}>
{hideOnScroll && (
<Link className={styles.sidebarLogo} to={logoLink} {...logoLinkProps}>
<Link
tabIndex="-1"
className={styles.sidebarLogo}
to={logoLink}
{...logoLinkProps}>
{logoImageUrl != null && (
<img key={isClient} src={logoImageUrl} alt={logoAlt} />
)}
Expand Down

0 comments on commit 2c4490a

Please sign in to comment.