mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
fix(theme): do not show tab content when tabbing over it; show after selection only (#8161)
This commit is contained in:
parent
44af538153
commit
b0d431af3b
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
|
@ -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]!;
|
||||
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue