Skip to content

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

:art: Keep scrollable tooltips visible on hover https://github.com/siyuan-note/siyuan/issues/18231

Daniel9be711d63f4d
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 6b61146fd0..b904fd3d1d 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -1,7 +1,7 @@
import {BlockPanel} from "./Panel";
import {hasClosestByAttribute, hasClosestByClassName,} from "../protyle/util/hasClosest";
import {fetchPost, fetchSyncPost} from "../util/fetch";
-import {hideTooltip, showTooltip, tooltipTargetElement} from "../dialog/tooltip";
+import {hideTooltip, showTooltip} from "../dialog/tooltip";
import {isLocalPath, parseSiYuanUriInfo} from "../util/pathName";
import {App} from "../index";
import {Constants} from "../constants";
@@ -211,11 +211,7 @@ export const initBlockPopover = (app: App) => {
}
} else if (!aElement) {
const tipElement = hasClosestByAttribute(event.target, "id", "tooltip", true);
- if (!tipElement) {
- hideTooltip();
- } else if (tooltipTargetElement && !tooltipTargetElement.contains(event.target)) {
- // 鼠标在 #tooltip 上但已离开触发元素范围,正常隐藏
- // 仍在触发元素范围内时不隐藏,避免 showTooltip ↔ hideTooltip 循环闪烁
+ if (!tipElement || tipElement.clientHeight >= tipElement.scrollHeight) {
hideTooltip();
}
}
diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts
index d10db5ef57..6b6f980c20 100644
--- a/app/src/dialog/tooltip.ts
+++ b/app/src/dialog/tooltip.ts
@@ -1,8 +1,5 @@
import {isMobile} from "../util/functions";
-// 记录当前 tooltip 对应的触发元素,便于判断鼠标是否已离开触发区域
-export let tooltipTargetElement: Element | null = null;
-
export const showTooltip = (
message: string,
target: Element,
@@ -13,7 +10,6 @@ export const showTooltip = (
if (isMobile() || !message) {
return;
}
- tooltipTargetElement = target;
let targetRect = target.getBoundingClientRect();
// 跨行元素
const clientRects = Array.from(target.getClientRects());
@@ -137,6 +133,5 @@ export const showTooltip = (
};
export const hideTooltip = () => {
- tooltipTargetElement = null;
document.getElementById("tooltip").classList.add("fn__none");
};