@@ -72,10 +72,12 @@ export class Tooltip extends PopoverContainer implements AfterContentChecked {
7272 /**
7373 * Optional data for templates passed as implicit context
7474 */
75- @Input ( ) templateContext : any
75+ @Input ( ) templateContext : any ;
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 }
0 commit comments