Skip to content

Commit 6d7abac

Browse files
committed
fix(tooltip): Sometimes tooltip flashes
1 parent 5ce0383 commit 6d7abac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/client/src/services/note_tooltip.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { t } from "./i18n.js";
1010

1111
// Track all elements that open tooltips
1212
let openTooltipElements: JQuery<HTMLElement>[] = [];
13+
let dismissTimer: ReturnType<typeof setTimeout>;
1314

1415
function setupGlobalTooltip() {
1516
$(document).on("mouseenter", "a", mouseEnterHandler);
@@ -26,6 +27,7 @@ function setupGlobalTooltip() {
2627
}
2728

2829
function dismissAllTooltips() {
30+
clearTimeout(dismissTimer);
2931
openTooltipElements.forEach($el => {
3032
$el.tooltip("dispose");
3133
$el.removeAttr("aria-describedby");
@@ -129,11 +131,11 @@ async function mouseEnterHandler(this: HTMLElement) {
129131
// cursor is neither over the link nor over the tooltip, user likely is not interested
130132
dismissAllTooltips();
131133
} else {
132-
setTimeout(checkTooltip, 1000);
134+
dismissTimer = setTimeout(checkTooltip, 1000);
133135
}
134136
};
135137

136-
setTimeout(checkTooltip, 1000);
138+
dismissTimer = setTimeout(checkTooltip, 1000);
137139
}
138140
}
139141

0 commit comments

Comments
 (0)