File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ export class Tooltip extends PopoverContainer implements AfterContentChecked {
7676
7777 @ViewChild ( "contentWrapper" ) wrapper : ElementRef < HTMLSpanElement > ;
7878
79+ private timeoutId : any ; // it should be number, but setTimeout below is matching the NodeJs type instead of the JS type
80+
7981 constructor (
8082 protected elementRef : ElementRef ,
8183 protected ngZone : NgZone ,
@@ -89,14 +91,20 @@ export class Tooltip extends PopoverContainer implements AfterContentChecked {
8991
9092 @HostListener ( "mouseenter" , [ "$event" ] )
9193 mouseenter ( event ) {
92- setTimeout ( ( ) => {
94+ // If a mouseleave is triggered before the tooltip is displayed (before setTimeout of mouseenter completes)
95+ // we trigger the mouseleave only avoiding having to unecessary show the tooltip
96+ clearTimeout ( this . timeoutId ) ;
97+ this . timeoutId = setTimeout ( ( ) => {
9398 this . handleChange ( true , event ) ;
9499 } , this . enterDelayMs ) ;
95100 }
96101
97102 @HostListener ( "mouseleave" , [ "$event" ] )
98103 mouseleave ( event ) {
99- setTimeout ( ( ) => {
104+ // If a mouseleave is triggered before the tooltip is displayed (before setTimeout of mouseenter completes)
105+ // we trigger the mouseleave only avoiding having to unecessary show the tooltip
106+ clearTimeout ( this . timeoutId ) ;
107+ this . timeoutId = setTimeout ( ( ) => {
100108 this . handleChange ( false , event ) ;
101109 } , this . leaveDelayMs ) ;
102110 }
You can’t perform that action at this time.
0 commit comments