fix(theme): do not show tab content when tabbing over it; show after selection only (#8161)

This commit is contained in:
mturoci 2022-10-05 19:10:08 +02:00 committed by GitHub
parent 44af538153
commit b0d431af3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(