Skip to content

Commit 00d2391

Browse files
authored
Merge branch 'master' into issue.2861
2 parents 90af058 + 8ff0322 commit 00d2391

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/tooltip/tooltip.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)