mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 13:22:26 +02:00
fix(v2): select correct tab when items are incorrectly ordered (#4468)
This commit is contained in:
parent
61548d3995
commit
80e40c36e5
2 changed files with 7 additions and 5 deletions
|
@ -46,10 +46,12 @@ function Tabs(props: Props): JSX.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTabChange = (event) => {
|
const handleTabChange = (
|
||||||
const selectedTab = event.target;
|
event: React.FocusEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>,
|
||||||
|
) => {
|
||||||
|
const selectedTab = event.currentTarget;
|
||||||
const selectedTabIndex = tabRefs.indexOf(selectedTab);
|
const selectedTabIndex = tabRefs.indexOf(selectedTab);
|
||||||
const selectedTabValue = children[selectedTabIndex].props.value;
|
const selectedTabValue = values[selectedTabIndex].value;
|
||||||
|
|
||||||
setSelectedValue(selectedTabValue);
|
setSelectedValue(selectedTabValue);
|
||||||
|
|
||||||
|
|
|
@ -429,8 +429,8 @@ declare module '@theme/TabItem' {
|
||||||
export type Props = {
|
export type Props = {
|
||||||
readonly children: ReactNode;
|
readonly children: ReactNode;
|
||||||
readonly value: string;
|
readonly value: string;
|
||||||
readonly hidden: boolean;
|
readonly hidden?: boolean;
|
||||||
readonly className: string;
|
readonly className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TabItem: (props: Props) => JSX.Element;
|
const TabItem: (props: Props) => JSX.Element;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue