File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ class SLDSTooltip extends React.Component {
39
39
} ;
40
40
}
41
41
42
+ componentDidMount ( ) {
43
+ this . setState ( { isMounted : true } ) ;
44
+ }
45
+
46
+ componentWillUnmount ( ) {
47
+ this . setState ( { isMounted : false } ) ;
48
+ }
49
+
42
50
handleMouseClick ( ) {
43
51
this . setState ( {
44
52
isOpen : ! this . state . isOpen ,
@@ -55,9 +63,10 @@ class SLDSTooltip extends React.Component {
55
63
}
56
64
57
65
handleMouseLeave ( ) {
58
- this . setState ( { isClosing : true } ) ;
66
+ this . setState ( { isClosing : true } ) ;
67
+
59
68
setTimeout ( ( ) => {
60
- if ( this . isMounted && this . state . isClosing ) {
69
+ if ( this . state . isMounted && this . state . isClosing ) {
61
70
this . setState ( {
62
71
isOpen : false ,
63
72
isClosing : false
@@ -119,7 +128,7 @@ class SLDSTooltip extends React.Component {
119
128
horizontalAlign = { this . getHorizontalAlign ( ) }
120
129
verticalAlign = { this . getVerticalAlign ( ) }
121
130
flippable = { false }
122
- onClose = { this . handleCancel } >
131
+ onClose = { this . handleCancel . bind ( this ) } >
123
132
< div className = { cx ( style ) } role = "tooltip" >
124
133
{ this . getTooltipContent ( ) }
125
134
</ div >
@@ -128,7 +137,7 @@ class SLDSTooltip extends React.Component {
128
137
129
138
render ( ) {
130
139
return (
131
- < span refs = 'tooltipTarget' onClick = { this . props . openOn === 'click' ? this . handleMouseClick :null } onMouseEnter = { this . props . openOn === 'hover' ? this . handleMouseEnter . bind ( this ) :null } onMouseLeave = { this . props . openOn === 'hover' ? this . handleMouseLeave . bind ( this ) :null } >
140
+ < span refs = 'tooltipTarget' onClick = { this . props . openOn === 'click' ? this . handleMouseClick . bind ( this ) :null } onMouseEnter = { this . props . openOn === 'hover' ? this . handleMouseEnter . bind ( this ) :null } onMouseLeave = { this . props . openOn === 'hover' ? this . handleMouseLeave . bind ( this ) :null } >
132
141
{ this . props . children }
133
142
{ this . getTooltip ( ) }
134
143
</ span >
You can’t perform that action at this time.
0 commit comments