Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/14905

Danieldf69dd1ef8db
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 9579a40458..07faa41ac5 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -1,7 +1,7 @@
import {BlockPanel} from "./Panel";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName,} from "../protyle/util/hasClosest";
import {fetchPost, fetchSyncPost} from "../util/fetch";
-import {hideTooltip, showTooltip} from "../dialog/tooltip";
+import {hideTooltip, showTooltip, tooltipTargetElement} from "../dialog/tooltip";
import {getIdFromSYProtocol, isLocalPath} from "../util/pathName";
import {App} from "../index";
import {Constants} from "../constants";
@@ -213,9 +213,11 @@ export const initBlockPopover = (app: App) => {
const tipElement = hasClosestByAttribute(event.target, "id", "tooltip", true);
if (!tipElement) {
hideTooltip();
+ } else if (tooltipTargetElement && !tooltipTargetElement.contains(event.target)) {
+ // 鼠标在 #tooltip 上但已离开触发元素范围,正常隐藏
+ // 仍在触发元素范围内时不隐藏,避免 showTooltip ↔ hideTooltip 循环闪烁
+ hideTooltip();
}
- // 鼠标仍在 #tooltip 上时不主动隐藏,避免 showTooltip ↔ hideTooltip 循环闪烁;
- // 待鼠标移到非 tooltip 处再由上面的分支隐藏
}
if (window.siyuan.config.editor.floatWindowMode === 1 || window.siyuan.shiftIsPressed) {
clearTimeout(timeoutHide);
diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts
index 7af35370fc..8a1241782d 100644
--- a/app/src/dialog/tooltip.ts
+++ b/app/src/dialog/tooltip.ts
@@ -1,5 +1,8 @@
import {isMobile} from "../util/functions";
+// 记录当前 tooltip 对应的触发元素,便于判断鼠标是否已离开触发区域
+export let tooltipTargetElement: Element | null = null;
+
export const showTooltip = (
message: string,
target: Element,
@@ -10,6 +13,7 @@ export const showTooltip = (
if (isMobile() || !message) {
return;
}
+ tooltipTargetElement = target;
let targetRect = target.getBoundingClientRect();
// 跨行元素
const clientRects = Array.from(target.getClientRects());
@@ -128,5 +132,6 @@ export const showTooltip = (
};
export const hideTooltip = () => {
+ tooltipTargetElement = null;
document.getElementById("tooltip").classList.add("fn__none");
};