@@ -46,7 +46,6 @@ const Tooltip = ({
4646 const [ show , setShow ] = useState ( false )
4747 const [ rendered , setRendered ] = useState ( false )
4848 const wasShowing = useRef ( false )
49- const [ calculatingPosition , setCalculatingPosition ] = useState ( false )
5049 const lastFloatPosition = useRef < IPosition | null > ( null )
5150 const { anchorRefs, setActiveAnchor : setProviderActiveAnchor } = useTooltip ( id )
5251 const [ activeAnchor , setActiveAnchor ] = useState < React . RefObject < HTMLElement > > ( { current : null } )
@@ -62,8 +61,8 @@ const Tooltip = ({
6261 setRendered ( true )
6362
6463 /**
65- * this `timeout` is necessary because the component
66- * needs to be rendered to calculate the position correctly
64+ * wait for the component to render and calculate position
65+ * before actually showing
6766 */
6867 setTimeout ( ( ) => {
6968 if ( setIsOpen ) {
@@ -132,7 +131,7 @@ const Tooltip = ({
132131 const handleHideTooltip = ( ) => {
133132 if ( clickable ) {
134133 // allow time for the mouse to reach the tooltip, in case there's a gap
135- handleHideTooltipDelayed ( delayHide || 50 )
134+ handleHideTooltipDelayed ( delayHide || 100 )
136135 } else if ( delayHide ) {
137136 handleHideTooltipDelayed ( )
138137 } else {
@@ -159,7 +158,6 @@ const Tooltip = ({
159158 }
160159 } ,
161160 } as Element
162- setCalculatingPosition ( true )
163161 computeTooltipPosition ( {
164162 place,
165163 offset,
@@ -169,7 +167,6 @@ const Tooltip = ({
169167 strategy : positionStrategy ,
170168 middlewares,
171169 } ) . then ( ( computedStylesData ) => {
172- setCalculatingPosition ( false )
173170 if ( Object . keys ( computedStylesData . tooltipStyles ) . length ) {
174171 setInlineStyles ( computedStylesData . tooltipStyles )
175172 }
@@ -350,7 +347,6 @@ const Tooltip = ({
350347 // `anchorId` element takes precedence
351348 elementReference = document . querySelector ( `[id='${ anchorId } ']` ) as HTMLElement
352349 }
353- setCalculatingPosition ( true )
354350 let mounted = true
355351 computeTooltipPosition ( {
356352 place,
@@ -365,7 +361,6 @@ const Tooltip = ({
365361 // invalidate computed positions after remount
366362 return
367363 }
368- setCalculatingPosition ( false )
369364 if ( Object . keys ( computedStylesData . tooltipStyles ) . length ) {
370365 setInlineStyles ( computedStylesData . tooltipStyles )
371366 }
@@ -402,10 +397,7 @@ const Tooltip = ({
402397
403398 const hasContentOrChildren = Boolean ( html || content || children )
404399 const canShow = Boolean (
405- hasContentOrChildren &&
406- ! calculatingPosition &&
407- ( isOpen || show ) &&
408- Object . keys ( inlineStyles ) . length > 0 ,
400+ hasContentOrChildren && ( isOpen || show ) && Object . keys ( inlineStyles ) . length > 0 ,
409401 )
410402
411403 return rendered ? (
0 commit comments