Skip to content

Improve tooltip display in asynchronous callbacks - #17872

Closed
TCOTC wants to merge 1 commit into
siyuan-note:devfrom
TCOTC:fix/tooltip-display
Closed

Improve tooltip display in asynchronous callbacks#17872
TCOTC wants to merge 1 commit into
siyuan-note:devfrom
TCOTC:fix/tooltip-display

Conversation

@TCOTC

@TCOTC TCOTC commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description / 描述

fix #14823

在异步回调中显示 Tooltip 前,先检查鼠标指针是否仍在对应元素上。

Type of change / 变更类型

  • Bug fix
    缺陷修复
  • Refactoring
    代码重构
  • New feature
    新功能
  • Text updates or new language additions
    修改文案或增加新语言

Checklist / 检查清单

  • I have performed a self-review of my own code
    我对自己的代码进行了自我审查
  • I have full rights to the submitted code and agree to license it under this project's AGPL-3.0 license
    我拥有所提交代码的完整权利,并同意其以本项目的 AGPL-3.0 许可证授权
  • PR is submitted to the dev branch and has no merge conflicts
    PR 提交到 dev 分支,并且没有合并冲突

Check if the mouse pointer is still over the corresponding element before displaying the Tooltip in an asynchronous callback.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #14823 by preventing tooltips from being shown after asynchronous callbacks if the mouse pointer is no longer over the original target element, reducing “stuck tooltip” occurrences in fast hover-to-leave scenarios.

Changes:

  • Added showTooltipIfPointerOver() (and helper isPointerOverElement()) to guard tooltip display in async callbacks.
  • Updated tab header tooltip and block popover async tooltip flows to use the guarded tooltip display.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
app/src/layout/Tab.ts Uses guarded tooltip display for async tab path tooltip.
app/src/dialog/tooltip.ts Introduces pointer-over check helper and guarded tooltip function for async scenarios.
app/src/block/popover.ts Uses guarded tooltip display for async asset/notebook info tooltips to avoid late popups.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/dialog/tooltip.ts
Comment on lines +3 to +10
export const isPointerOverElement = (target: Element) => {
const coords = window.siyuan.coordinates;
if (!coords) {
return false;
}
const underMouse = document.elementFromPoint(coords.clientX, coords.clientY) as HTMLElement;
return !!underMouse && (target === underMouse || target.contains(underMouse));
};
@Vanessa219

Copy link
Copy Markdown
Member

使用 AbortController 方案从根本上解决。这个方案我就关闭了。

@Vanessa219 Vanessa219 closed this Jun 17, 2026
@TCOTC
TCOTC deleted the fix/tooltip-display branch June 19, 2026 01:22
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants