import { ComponentPropsWithRef , forwardRef , Ref , useRef } from 'react' ; type Props = ComponentPropsWithRef < 'details' > ; const Details = ( { children , className , onToggle , open , ... props } , ref ) => { const initialToggle = useRef ( true ) ; return ( < details className = { className } ref = { ref } open = { open } onToggle = { ( e ) => { if ( initialToggle . current ) { initialToggle . current = false ; if ( open ) { return ; } } onToggle ?. ( e ) ; } } { ... props } > { children } < /details>); } ; export default forwardRef < HTMLDetailsElement , Props > ( Details ) ;