docs: fix error on collapsing prerequisites (#10153)

This commit is contained in:
Shahed Nasser
2024-11-19 13:35:47 +02:00
committed by GitHub
parent 39e81d8d21
commit 3b1463048a
2 changed files with 11 additions and 2 deletions
@@ -11,6 +11,7 @@ export type CollapsibleProps = {
onClose?: () => void
unmountOnExit?: boolean
childrenRef?: React.RefObject<HTMLElement | null>
useChild?: boolean
}
export type CollapsibleReturn = {
@@ -26,10 +27,15 @@ export const useCollapsible = ({
onClose,
unmountOnExit = true,
childrenRef,
useChild = true,
}: CollapsibleProps): CollapsibleReturn => {
const [collapsed, setCollapsed] = useState(initialValue)
const getNodeFromChildrenRef = () => {
if (!useChild) {
return childrenRef?.current
}
return (
(childrenRef?.current?.firstElementChild as HTMLElement) ||
childrenRef?.current