Skip to content

Commit

Permalink
fix(theme): do not show tab content when tabbing over it; show after …
Browse files Browse the repository at this point in the history
…selection only (#8161)
  • Loading branch information
mturoci authored and slorber committed Oct 28, 2022
1 parent 55c0abc commit 08b4caa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/docusaurus-theme-classic/src/theme/Tabs/index.tsx
Expand Up @@ -104,7 +104,10 @@ function TabsComponent(props: Props): JSX.Element {
}

const handleTabChange = (
event: React.FocusEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>,
event:
| React.FocusEvent<HTMLLIElement>
| React.MouseEvent<HTMLLIElement>
| React.KeyboardEvent<HTMLLIElement>,
) => {
const newTab = event.currentTarget;
const newTabIndex = tabRefs.indexOf(newTab);
Expand All @@ -124,6 +127,10 @@ function TabsComponent(props: Props): JSX.Element {
let focusElement: HTMLLIElement | null = null;

switch (event.key) {
case 'Enter': {
handleTabChange(event);
break;
}
case 'ArrowRight': {
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
focusElement = tabRefs[nextTab] ?? tabRefs[0]!;
Expand Down Expand Up @@ -161,7 +168,6 @@ function TabsComponent(props: Props): JSX.Element {
key={value}
ref={(tabControl) => tabRefs.push(tabControl)}
onKeyDown={handleKeydown}
onFocus={handleTabChange}
onClick={handleTabChange}
{...attributes}
className={clsx(
Expand Down

0 comments on commit 08b4caa

Please sign in to comment.