mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
fix(tooltip): Sometimes tooltip flashes
This commit is contained in:
parent
5ce0383c03
commit
6d7abace97
@ -10,6 +10,7 @@ import { t } from "./i18n.js";
|
|||||||
|
|
||||||
// Track all elements that open tooltips
|
// Track all elements that open tooltips
|
||||||
let openTooltipElements: JQuery<HTMLElement>[] = [];
|
let openTooltipElements: JQuery<HTMLElement>[] = [];
|
||||||
|
let dismissTimer: ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
function setupGlobalTooltip() {
|
function setupGlobalTooltip() {
|
||||||
$(document).on("mouseenter", "a", mouseEnterHandler);
|
$(document).on("mouseenter", "a", mouseEnterHandler);
|
||||||
@ -26,6 +27,7 @@ function setupGlobalTooltip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dismissAllTooltips() {
|
function dismissAllTooltips() {
|
||||||
|
clearTimeout(dismissTimer);
|
||||||
openTooltipElements.forEach($el => {
|
openTooltipElements.forEach($el => {
|
||||||
$el.tooltip("dispose");
|
$el.tooltip("dispose");
|
||||||
$el.removeAttr("aria-describedby");
|
$el.removeAttr("aria-describedby");
|
||||||
@ -129,11 +131,11 @@ async function mouseEnterHandler(this: HTMLElement) {
|
|||||||
// cursor is neither over the link nor over the tooltip, user likely is not interested
|
// cursor is neither over the link nor over the tooltip, user likely is not interested
|
||||||
dismissAllTooltips();
|
dismissAllTooltips();
|
||||||
} else {
|
} else {
|
||||||
setTimeout(checkTooltip, 1000);
|
dismissTimer = setTimeout(checkTooltip, 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
setTimeout(checkTooltip, 1000);
|
dismissTimer = setTimeout(checkTooltip, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user