mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 19:03:38 +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 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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue