1
- import React , { forwardRef , Fragment , useLayoutEffect , useState , useRef } from "react"
1
+ import React , { forwardRef , Fragment , useLayoutEffect } from "react"
2
2
import Drop from "src/components/drops/drop"
3
3
import useForwardRef from "src/hooks/use-forward-ref"
4
4
import useToggle from "src/hooks/use-toggle"
@@ -21,28 +21,19 @@ const Tooltip = forwardRef(
21
21
disabled,
22
22
zIndex = 80 ,
23
23
children,
24
- onClickOutside,
25
24
allowHoverOnTooltip,
26
25
...rest
27
26
} ,
28
27
parentRef
29
28
) => {
30
29
const id = useDescribedId ( rest [ "aria-describedby" ] )
31
30
const [ isOpen , , open , close ] = useToggle ( false )
32
- const [ hasPopUpHovered , setHasPopUpHovered ] = useState ( false )
33
- const closeWithDelayTimeout = useRef ( )
34
31
35
32
const [ ref , setRef ] = useForwardRef ( parentRef )
36
33
37
- const handleCloseWithDelay = ( ) => {
38
- closeWithDelayTimeout . current = setTimeout ( ( ) => {
39
- close ( )
40
- } , 200 )
41
- }
42
-
43
34
const targetElement = useClonedChildren ( children , setRef , {
44
35
onMouseEnter : open ,
45
- onMouseLeave : allowHoverOnTooltip ? handleCloseWithDelay : close ,
36
+ onMouseLeave : ! allowHoverOnTooltip ? close : undefined ,
46
37
onFocus : open ,
47
38
onBlur : close ,
48
39
...( isOpen && { "aria-describedby" : id } ) ,
@@ -53,12 +44,6 @@ const Tooltip = forwardRef(
53
44
if ( ref . current && initialOpen ) open ( )
54
45
} , [ ] )
55
46
56
- useLayoutEffect ( ( ) => {
57
- if ( hasPopUpHovered && closeWithDelayTimeout . current ) {
58
- clearTimeout ( closeWithDelayTimeout . current )
59
- }
60
- } , [ hasPopUpHovered ] )
61
-
62
47
if ( ! content ) {
63
48
return children
64
49
}
@@ -72,11 +57,7 @@ const Tooltip = forwardRef(
72
57
hideShadow
73
58
id = { id }
74
59
onClickOutside = { close }
75
- onMouseLeave = { ( ) => {
76
- setHasPopUpHovered ( false )
77
- close ( )
78
- } }
79
- onMouseEnter = { ( ) => setHasPopUpHovered ( true ) }
60
+ onMouseLeave = { close }
80
61
target = { ref . current }
81
62
{ ...dropProps }
82
63
animation = { animation }
0 commit comments