@@ -202,7 +202,6 @@ class ReactTooltip extends Component {
202
202
203
203
// If it is focus event, switch to `solid` effect
204
204
const isFocus = e instanceof window . FocusEvent
205
-
206
205
this . setState ( {
207
206
placeholder,
208
207
place : e . currentTarget . getAttribute ( 'data-place' ) || this . props . place || 'top' ,
@@ -246,8 +245,7 @@ class ReactTooltip extends Component {
246
245
const delayTime = show ? 0 : parseInt ( delayShow , 10 )
247
246
const eventTarget = e . currentTarget
248
247
249
- clearTimeout ( this . delayShowLoop )
250
- this . delayShowLoop = setTimeout ( ( ) => {
248
+ const updateState = ( ) => {
251
249
if ( typeof placeholder === 'string' ) placeholder = placeholder . trim ( )
252
250
if ( Array . isArray ( placeholder ) && placeholder . length > 0 || placeholder ) {
253
251
this . setState ( {
@@ -258,7 +256,14 @@ class ReactTooltip extends Component {
258
256
this . updatePosition ( )
259
257
} )
260
258
}
261
- } , delayTime )
259
+ }
260
+
261
+ if ( delayShow ) {
262
+ clearTimeout ( this . delayShowLoop )
263
+ this . delayShowLoop = setTimeout ( updateState , delayTime )
264
+ } else {
265
+ updateState ( )
266
+ }
262
267
}
263
268
264
269
/**
@@ -269,14 +274,21 @@ class ReactTooltip extends Component {
269
274
270
275
if ( ! this . mount ) return
271
276
272
- this . clearTimer ( )
273
- this . delayHideLoop = setTimeout ( ( ) => {
277
+ const resetState = ( resetPlace ) => {
278
+ const newPlace = resetPlace ? '' : this . state . place
274
279
this . setState ( {
275
280
show : false ,
276
- place : ''
281
+ place : newPlace
277
282
} )
278
283
this . removeScrollListener ( )
279
- } , parseInt ( delayHide , 10 ) )
284
+ }
285
+
286
+ if ( delayHide ) {
287
+ this . clearTimer ( )
288
+ this . delayHideLoop = setTimeout ( resetState , parseInt ( delayHide , 10 ) )
289
+ } else {
290
+ resetState ( true )
291
+ }
280
292
}
281
293
282
294
/**
0 commit comments