fix(v2): select correct tab when items are incorrectly ordered (#4468)

This commit is contained in:
Armano 2021-03-19 18:12:58 +01:00 committed by GitHub
parent 61548d3995
commit 80e40c36e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -46,10 +46,12 @@ function Tabs(props: Props): JSX.Element {
}
}
const handleTabChange = (event) => {
const selectedTab = event.target;
const handleTabChange = (
event: React.FocusEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>,
) => {
const selectedTab = event.currentTarget;
const selectedTabIndex = tabRefs.indexOf(selectedTab);
const selectedTabValue = children[selectedTabIndex].props.value;
const selectedTabValue = values[selectedTabIndex].value;
setSelectedValue(selectedTabValue);

View file

@ -429,8 +429,8 @@ declare module '@theme/TabItem' {
export type Props = {
readonly children: ReactNode;
readonly value: string;
readonly hidden: boolean;
readonly className: string;
readonly hidden?: boolean;
readonly className?: string;
};
const TabItem: (props: Props) => JSX.Element;