diff --git a/src/theme/TabItem/index.tsx b/src/theme/TabItem/index.tsx index 91055fe99b0..b3e0c55f83a 100644 --- a/src/theme/TabItem/index.tsx +++ b/src/theme/TabItem/index.tsx @@ -1,6 +1,7 @@ import React from 'react'; import TabItem from '@theme-original/TabItem'; import type {WrapperProps} from '@docusaurus/types'; +import {useTabs} from '@docusaurus/theme-common/internal'; import styles from './styles.module.css'; type Props = WrapperProps; @@ -9,7 +10,10 @@ type Props = WrapperProps; // uses https://docusaurus.io/docs/swizzling#wrapping // to wrap the original TabItem component and add a contextual label based on the tab value export default function TabItemWrapper(props: Props): JSX.Element { - const {hidden, value, ...otherProps} = props; + const {value} = props; + // Docusaurus >= 3.10 no longer passes `hidden`; derive it from the tabs context + const {selectedValue} = useTabs(); + const hidden = value !== selectedValue; // Generate contextual label based on tab value const getContextLabel = (tabValue: string) => { @@ -29,7 +33,8 @@ export default function TabItemWrapper(props: Props): JSX.Element {
{getContextLabel(value)}
- + {/* always "selected" so TabItem never sets the `hidden` attribute */} + ); }