Skip to content

fix(tooltip): 修复部分情况下 ToolTip 不显示的问题,并调整了偏移量 - #3508

Open
Pigeon0v0 wants to merge 3 commits into
devfrom
fix/tooltip
Open

fix(tooltip): 修复部分情况下 ToolTip 不显示的问题,并调整了偏移量#3508
Pigeon0v0 wants to merge 3 commits into
devfrom
fix/tooltip

Conversation

@Pigeon0v0

@Pigeon0v0 Pigeon0v0 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Co-worked with GPT-5.6 Sol xHigh

Summary by Sourcery

改进各类 UI 元素的工具提示显示行为和定位。

错误修复:

  • 确保工具提示能正确显示在已启用的元素上,不会被之前的目标或关闭状态所抑制。
  • 将 ComboBox 和 ComboBoxItem 视为共享同一祖先元素,这样在它们之间移动时工具提示能够保持激活状态。

增强:

  • 调整基于鼠标的工具提示放置模式和偏移,使工具提示显示在更靠近、并始终位于光标左侧的位置。
Original summary in English

Summary by Sourcery

Improve tooltip display behavior and positioning across various UI elements.

Bug Fixes:

  • Ensure tooltips appear correctly for enabled elements without being suppressed by previous targets or closing state.
  • Treat ComboBox and ComboBoxItem as sharing an ancestor so tooltips remain active when moving between them.

Enhancements:

  • Adjust mouse-based tooltip placement mode and offsets so tooltips appear closer and consistently to the left of the cursor.

@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: M PR 大小评估:中型 labels Aug 6, 2026
@sourcery-ai

sourcery-ai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

调整工具提示打开逻辑,以正确显示启用控件的工具提示;改进对 ComboBox/ComboBoxItem 的祖先检测,从而正确识别工具提示归属;并微调基于鼠标的工具提示位置偏移/放置模式;其余 XAML 文件似乎是非功能性更改(可能是格式/元数据)。

更新后工具提示打开逻辑的序列图

sequenceDiagram
    participant Mouse
    participant Tooltip
    participant fe as FrameworkElement
    participant Flyout as Flyout

    Mouse->>Tooltip: OnOpening(fe)
    alt [fe is null or not FrameworkElement]
        Tooltip->>Tooltip: _Hush()
        Tooltip-->>Mouse: return
    else fe.IsEnabled
        alt ReferenceEquals(_target, fe) and _flyout.IsOpen
            Tooltip-->>Mouse: return
        else not ReferenceEquals(_target, fe)
            Tooltip->>Tooltip: _Hush()
        end
        Tooltip->>Tooltip: _latch.Stop()
        Tooltip->>Tooltip: _PopUp(fe, _cursor)
        Tooltip-->>Mouse: return
    else not fe.IsEnabled
        alt not ReferenceEquals(_target, fe)
            Tooltip->>Tooltip: _Hush()
        end
        Tooltip->>Tooltip: _StartCycle(fe, _cursor)
    end
Loading

File-Level Changes

Change Details Files
修复启用控件的工具提示打开行为,避免工具提示卡住/隐藏,并在目标变更时正确重新打开。
  • 重构启用状态下 FrameworkElement 的 OnOpening 逻辑,在同一工具提示已打开时提前返回。
  • 确保将悬停从一个目标切换到另一个目标时,会静默关闭此前的工具提示、重置内部闩锁状态、更新当前目标,并在当前鼠标位置打开弹出窗口。
  • 将此前“禁用分支”的代码路径移动,使其仅在元素未启用时执行。
PCL.Core/UI/Controls/Tooltip.cs
放宽在占用逻辑中的工具提示关闭保护。
  • 移除 _closing_TryClaim 中的保护,使得即使刚刚进行过关闭操作,工具提示循环仍然可以启动。
PCL.Core/UI/Controls/Tooltip.cs
改进 ComboBox 与 ComboBoxItem 之间的祖先共享检测,以在与下拉项交互时保持工具提示处于激活状态。
  • 扩展 _ShareAncestor,通过检查 ItemsControl.ItemsControlFromItemContainer,将 ComboBox 与其 ComboBoxItem 容器视为共享祖先。
  • 在新的 ComboBox 特定检查之后保留现有的可视树遍历逻辑。
PCL.Core/UI/Controls/Tooltip.cs
调整基于鼠标的工具提示放置模式和偏移,以获得更好的定位效果。
  • 在使用 PlacementMode.Mouse 时,将工具提示放置模式从 PlacementMode.Relative 改为 PlacementMode.Left
  • 在保持水平偏移公式基本不变并继续尊重 ToolTipService 偏移的前提下,将垂直偏移从 pt.Y + 25 降低为 pt.Y + 15
PCL.Core/UI/Controls/Tooltip.cs
若干 XAML 文件中的非功能性更新(可能是格式或项目级元数据)。
  • 变更了 Application.xaml 和若干页面 XAML 文件,在提供的 diff 中未见明显行为变化;评审者应确认在仅空白变更中是否隐藏了资源或绑定修改。
Plain Craft Launcher 2/Application.xaml
Plain Craft Launcher 2/Pages/PageDownload/Comp/MyCompItem.xaml
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceSetup.xaml
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • 触发新评审: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub issue: 通过回复评审评论请求 Sourcery 从该评论创建 issue。也可以回复评审评论 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题中任意位置写入 @sourcery-ai,即可随时生成标题。也可以在 pull request 中评论 @sourcery-ai title 来随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中任意位置写入 @sourcery-ai summary,即可在相应位置随时生成 PR 摘要。也可以在 pull request 中评论 @sourcery-ai summary 来随时(重新)生成摘要。
  • 生成评审者指南: 在 pull request 上评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 评审: 在 pull request 上评论 @sourcery-ai dismiss,即可撤销所有现有 Sourcery 评审。特别适用于希望从头开始新的评审——别忘了再评论 @sourcery-ai review 以触发新的评审!

Customizing Your Experience

访问你的 dashboard 以:

  • 启用或禁用评审特性,如 Sourcery 生成的 pull request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审指令。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Adjusts tooltip opening logic to correctly show tooltips for enabled controls, improves ancestor detection for ComboBox/ComboBoxItem so tooltip ownership is recognized, and tweaks mouse-based tooltip placement offsets/placement mode; remaining XAML files appear to have non-functional changes (likely formatting/metadata).

Sequence diagram for updated tooltip opening logic

sequenceDiagram
    participant Mouse
    participant Tooltip
    participant fe as FrameworkElement
    participant Flyout as Flyout

    Mouse->>Tooltip: OnOpening(fe)
    alt [fe is null or not FrameworkElement]
        Tooltip->>Tooltip: _Hush()
        Tooltip-->>Mouse: return
    else fe.IsEnabled
        alt ReferenceEquals(_target, fe) and _flyout.IsOpen
            Tooltip-->>Mouse: return
        else not ReferenceEquals(_target, fe)
            Tooltip->>Tooltip: _Hush()
        end
        Tooltip->>Tooltip: _latch.Stop()
        Tooltip->>Tooltip: _PopUp(fe, _cursor)
        Tooltip-->>Mouse: return
    else not fe.IsEnabled
        alt not ReferenceEquals(_target, fe)
            Tooltip->>Tooltip: _Hush()
        end
        Tooltip->>Tooltip: _StartCycle(fe, _cursor)
    end
Loading

File-Level Changes

Change Details Files
Fix tooltip opening behavior for enabled controls to avoid stuck/hidden tooltips and correctly re-open on target change.
  • Reworked OnOpening logic when the FrameworkElement is enabled to early-return if the same tooltip is already open.
  • Ensured that switching hover from one target to another hushes the previous tooltip, resets internal latch state, updates the current target, and opens the popup at the current mouse position.
  • Moved the previous disabled-branch code path so it only executes when the element is not enabled.
PCL.Core/UI/Controls/Tooltip.cs
Relax tooltip closing guard in claim logic.
  • Removed the _closing guard in _TryClaim so the tooltip cycle can still start even if a closing operation was recently in progress.
PCL.Core/UI/Controls/Tooltip.cs
Improve ancestor sharing detection between ComboBox and ComboBoxItem to keep tooltips active while interacting with dropdown items.
  • Extended _ShareAncestor to treat a ComboBox and its ComboBoxItem containers as sharing an ancestor by checking ItemsControl.ItemsControlFromItemContainer.
  • Preserved existing visual tree traversal logic after the new ComboBox-specific checks.
PCL.Core/UI/Controls/Tooltip.cs
Adjust mouse-based tooltip placement mode and offsets for better positioning.
  • Changed tooltip placement from PlacementMode.Relative to PlacementMode.Left when PlacementMode.Mouse is used.
  • Reduced vertical offset from pt.Y + 25 to pt.Y + 15 while keeping the horizontal offset formula similar, both still honoring ToolTipService offsets.
PCL.Core/UI/Controls/Tooltip.cs
Non-functional updates in several XAML files (likely formatting or project-level metadata).
  • Touched Application.xaml and several page XAML files without visible behavioral changes in the provided diff; reviewers should confirm there are no resource or binding modifications hidden in whitespace-only changes.
Plain Craft Launcher 2/Application.xaml
Plain Craft Launcher 2/Pages/PageDownload/Comp/MyCompItem.xaml
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceSetup.xaml
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey - 我已经留下了一些高层次的反馈:

  • OnOpening 中新的 fe.IsEnabled 分支和后面的部分逻辑重复(例如 _Hush_target 赋值、_latch 管理、_cursor),可以考虑重构以避免随着时间推移启用/禁用路径之间的行为出现偏差。
  • 你移除了 _TryClaim 中的 _closing 保护。如果 _closing 在其他地方仍然被使用,建议要么彻底移除该字段,要么说明为什么现在在关闭过程中允许可重入是安全的,以避免未来出现回归问题。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
-`OnOpening` 中新的 `fe.IsEnabled` 分支和后面的部分逻辑重复(例如 `_Hush``_target` 赋值、`_latch` 管理、`_cursor`),可以考虑重构以避免随着时间推移启用/禁用路径之间的行为出现偏差。
- 你移除了 `_TryClaim` 中的 `_closing` 保护。如果 `_closing` 在其他地方仍然被使用,建议要么彻底移除该字段,要么说明为什么现在在关闭过程中允许可重入是安全的,以避免未来出现回归问题。

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享它 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈改进后续评审。
Original comment in English

Hey - I've left some high level feedback:

  • The new fe.IsEnabled branch in OnOpening duplicates some of the logic that follows (e.g., _Hush, _target assignment, _latch management, _cursor), which could be refactored to avoid divergence between enabled/disabled paths over time.
  • You removed the _closing guard in _TryClaim; if _closing is still used elsewhere, consider either removing the field entirely or documenting why re-entrancy during closing is now safe to avoid future regressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `fe.IsEnabled` branch in `OnOpening` duplicates some of the logic that follows (e.g., `_Hush`, `_target` assignment, `_latch` management, `_cursor`), which could be refactored to avoid divergence between enabled/disabled paths over time.
- You removed the `_closing` guard in `_TryClaim`; if `_closing` is still used elsewhere, consider either removing the field entirely or documenting why re-entrancy during closing is now safe to avoid future regressions.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e0b2c0db8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +586 to +589
_flyout.Placement = PlacementMode.Left;
_flyout.PlacementRectangle = default;
_flyout.HorizontalOffset = Math.Round(pt.X + 15 + ToolTipService.GetHorizontalOffset(target));
_flyout.VerticalOffset = Math.Round(pt.Y + 25 + ToolTipService.GetVerticalOffset(target));
_flyout.VerticalOffset = Math.Round(pt.Y + 15 + ToolTipService.GetVerticalOffset(target));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep mouse placement relative to the pointer

When ToolTipService.Placement is Mouse (the default for the controls whose explicit placements were removed in this commit), PlacementMode.Left anchors the popup to the target's left edge, while pt.X/pt.Y are still offsets measured from the pointer within the target. As a result, the tooltip is positioned relative to the target edge rather than the cursor and can appear substantially displaced or fail to follow the cursor, especially on wide controls; this branch should retain a relative/mouse anchor when applying pointer-relative offsets.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M PR 大小评估:中型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant