diff --git a/components/DocMenu/react/DocMenu.tsx b/components/DocMenu/react/DocMenu.tsx index 05044322c..3186b7b72 100644 --- a/components/DocMenu/react/DocMenu.tsx +++ b/components/DocMenu/react/DocMenu.tsx @@ -21,11 +21,11 @@ export const DocMenu: React.FC = ({ {items.map((item, index) => 'items' in item ? (
  • - +
  • ) : ( - ) + ), )} ) diff --git a/components/DocMenu/react/_DocGroup.tsx b/components/DocMenu/react/_DocGroup.tsx index cca4d64a4..1346692b3 100644 --- a/components/DocMenu/react/_DocGroup.tsx +++ b/components/DocMenu/react/_DocGroup.tsx @@ -5,6 +5,7 @@ import { NavGroup, classes } from '@cypress-design/constants-docmenu' import { DocLink } from './_DocLink' export interface DocGroupProps { + index: number group: NavGroup collapsible: boolean depth?: number @@ -16,6 +17,7 @@ export const DocGroup: React.FC = ({ collapsible, depth = 0, setHeight, + index, }) => { const [open, setOpen] = React.useState(depth === 0) const [itemsHeights, setItemsHeights] = React.useState( @@ -53,14 +55,14 @@ export const DocGroup: React.FC = ({ } const onSetHeightCallback = React.useCallback( - (index: number, height: number) => { + (height: number) => { setItemsHeights((prev) => { const newHeights = [...prev] newHeights[index] = height return newHeights }) }, - [setItemsHeights], + [setItemsHeights, index], ) const Head = collapsible ? 'button' : group.href ? 'a' : 'div' @@ -110,7 +112,7 @@ export const DocGroup: React.FC = ({ {group.items.map((item, index) => 'items' in item ? (
  • - = ({ ) } - -const DocGroupWithIndex: React.FC< - Omit & { - index: number - setHeight: (index: number, height: number) => void - } -> = ({ setHeight, index, ...props }) => { - const onSetHeight = React.useCallback( - (height: number) => { - setHeight(index, height) - }, - [index, setHeight], - ) - - return -}