@@ -46,7 +46,6 @@ const Tooltip = ({
46
46
const [ show , setShow ] = useState ( false )
47
47
const [ rendered , setRendered ] = useState ( false )
48
48
const wasShowing = useRef ( false )
49
- const [ calculatingPosition , setCalculatingPosition ] = useState ( false )
50
49
const lastFloatPosition = useRef < IPosition | null > ( null )
51
50
const { anchorRefs, setActiveAnchor : setProviderActiveAnchor } = useTooltip ( id )
52
51
const [ activeAnchor , setActiveAnchor ] = useState < React . RefObject < HTMLElement > > ( { current : null } )
@@ -62,8 +61,8 @@ const Tooltip = ({
62
61
setRendered ( true )
63
62
64
63
/**
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
67
66
*/
68
67
setTimeout ( ( ) => {
69
68
if ( setIsOpen ) {
@@ -132,7 +131,7 @@ const Tooltip = ({
132
131
const handleHideTooltip = ( ) => {
133
132
if ( clickable ) {
134
133
// allow time for the mouse to reach the tooltip, in case there's a gap
135
- handleHideTooltipDelayed ( delayHide || 50 )
134
+ handleHideTooltipDelayed ( delayHide || 100 )
136
135
} else if ( delayHide ) {
137
136
handleHideTooltipDelayed ( )
138
137
} else {
@@ -159,7 +158,6 @@ const Tooltip = ({
159
158
}
160
159
} ,
161
160
} as Element
162
- setCalculatingPosition ( true )
163
161
computeTooltipPosition ( {
164
162
place,
165
163
offset,
@@ -169,7 +167,6 @@ const Tooltip = ({
169
167
strategy : positionStrategy ,
170
168
middlewares,
171
169
} ) . then ( ( computedStylesData ) => {
172
- setCalculatingPosition ( false )
173
170
if ( Object . keys ( computedStylesData . tooltipStyles ) . length ) {
174
171
setInlineStyles ( computedStylesData . tooltipStyles )
175
172
}
@@ -350,7 +347,6 @@ const Tooltip = ({
350
347
// `anchorId` element takes precedence
351
348
elementReference = document . querySelector ( `[id='${ anchorId } ']` ) as HTMLElement
352
349
}
353
- setCalculatingPosition ( true )
354
350
let mounted = true
355
351
computeTooltipPosition ( {
356
352
place,
@@ -365,7 +361,6 @@ const Tooltip = ({
365
361
// invalidate computed positions after remount
366
362
return
367
363
}
368
- setCalculatingPosition ( false )
369
364
if ( Object . keys ( computedStylesData . tooltipStyles ) . length ) {
370
365
setInlineStyles ( computedStylesData . tooltipStyles )
371
366
}
@@ -402,10 +397,7 @@ const Tooltip = ({
402
397
403
398
const hasContentOrChildren = Boolean ( html || content || children )
404
399
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 ,
409
401
)
410
402
411
403
return rendered ? (
0 commit comments