File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -759,17 +759,29 @@ const Tooltip = ({
759759 } , [ updateTooltipPosition ] )
760760
761761 useEffect ( ( ) => {
762- if ( ! contentWrapperRef ?. current ) {
762+ if ( ! rendered || ! contentWrapperRef ?. current ) {
763763 return ( ) => null
764764 }
765+ const timeoutIds : Set < NodeJS . Timeout > = new Set ( )
765766 const contentObserver = new ResizeObserver ( ( ) => {
766- setTimeout ( ( ) => updateTooltipPosition ( ) )
767+ const timeoutId = setTimeout ( ( ) => {
768+ timeoutIds . delete ( timeoutId )
769+ if ( ! mounted . current ) {
770+ return
771+ }
772+ updateTooltipPosition ( )
773+ } )
774+ timeoutIds . add ( timeoutId )
767775 } )
768776 contentObserver . observe ( contentWrapperRef . current )
769777 return ( ) => {
770778 contentObserver . disconnect ( )
779+ timeoutIds . forEach ( ( timeoutId ) => {
780+ clearTimeout ( timeoutId )
781+ } )
782+ timeoutIds . clear ( )
771783 }
772- } , [ content , contentWrapperRef ?. current ] )
784+ } , [ rendered , contentWrapperRef ?. current ] )
773785
774786 useEffect ( ( ) => {
775787 const anchorById = document . querySelector < HTMLElement > ( `[id='${ anchorId } ']` )
You can’t perform that action at this time.
0 commit comments