Skip to content

fix: Abnormal behavior when dragging app icons to the tray window#1492

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
JWWTSL:master
Mar 10, 2026
Merged

fix: Abnormal behavior when dragging app icons to the tray window#1492
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
JWWTSL:master

Conversation

@JWWTSL
Copy link
Contributor

@JWWTSL JWWTSL commented Mar 10, 2026

log: The onActionsAlwaysVisibleChanged signal handler and closeStashPopupTimer timer in tray.qml failed to check the stashedPopup.dropHover state when determining whether to close the panel. This caused the panel to close immediately after drag-and-drop completion. Added a !stashedPopup.dropHover check to the panel closure condition to ensure the closure logic does not trigger while the user is dragging an icon onto the panel area.

pms: bug-336185

Summary by Sourcery

Bug Fixes:

  • Ensure the tray stash popup remains open during drag-and-drop when actions visibility changes or the close timer fires.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 10, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures the tray stashed popup is not closed while the user is hovering a dragged icon over it by incorporating the drop-hover state into existing close conditions.

Sequence diagram for tray popup closure with dropHover check

sequenceDiagram
    actor User
    participant Panel
    participant TraySortOrderModel
    participant closeStashPopupTimer
    participant stashedPopup

    User->>Panel: startDraggingIcon()
    Panel->>stashedPopup: open()
    User->>Panel: dragIconOverTray()
    Panel->>stashedPopup: setDropHover(true)

    TraySortOrderModel-->>Panel: onActionsAlwaysVisibleChanged(val=false)
    Panel->>Panel: check !val && !Panel.contextDragging && !stashedPopup.dropHover
    alt condition true
        Panel->>closeStashPopupTimer: start()
    else stashedPopup.dropHover is true
        Panel->>closeStashPopupTimer: doNotStart()
    end

    User->>Panel: dropIconOnTray()
    Panel->>stashedPopup: setDropHover(false)

    closeStashPopupTimer-->>Panel: onTriggered()
    Panel->>Panel: check !Panel.contextDragging && !stashedPopup.dropHover
    alt condition true
        Panel->>stashedPopup: close()
    else still dragging or hover
        Panel->>stashedPopup: keepOpen()
    end
Loading

State diagram for stashedPopup open and close behavior

stateDiagram-v2
    [*] --> Closed

    Closed --> OpenIdle: open()
    Closed --> OpenDropHover: openWithHover()

    OpenIdle --> Closed: onActionsAlwaysVisibleChanged && !Panel.contextDragging && !stashedPopup.dropHover
    OpenIdle --> Closed: closeStashPopupTimerTriggered && !Panel.contextDragging && !stashedPopup.dropHover
    OpenIdle --> OpenDropHover: setDropHoverTrue

    OpenDropHover --> OpenIdle: setDropHoverFalse

    OpenIdle --> [*]: forceClose()
    OpenDropHover --> [*]: forceClose()
Loading

File-Level Changes

Change Details Files
Prevent the stashed tray popup from closing while an icon is being dragged over it by factoring in the drop-hover state in close logic.
  • Update the actions-visibility change handler to require that the popup is not in drop-hover state before starting the close timer.
  • Tighten the close timer trigger condition so it only closes the popup when there is no context drag and the popup is not in drop-hover state.
panels/dock/tray/package/tray.qml

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The close conditions for the stash popup are now duplicated in both the signal handler and the timer; consider extracting this into a small helper function or property (e.g., shouldCloseStashPopup) to keep the logic consistent and easier to maintain.
  • Since dropHover is now part of the close condition, verify that its state is reliably reset (e.g., on drag leave or drop completion) to avoid cases where the popup may never close if dropHover stays true accidentally.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The close conditions for the stash popup are now duplicated in both the signal handler and the timer; consider extracting this into a small helper function or property (e.g., `shouldCloseStashPopup`) to keep the logic consistent and easier to maintain.
- Since `dropHover` is now part of the close condition, verify that its state is reliably reset (e.g., on drag leave or drop completion) to avoid cases where the popup may never close if `dropHover` stays true accidentally.

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.

log: The `onActionsAlwaysVisibleChanged` signal handler and `closeStashPopupTimer` timer in `tray.qml` failed to check the `stashedPopup.dropHover` state when determining whether to close the panel. This caused the panel to close immediately after drag-and-drop completion. Added a !stashedPopup.dropHover check to the panel closure condition to ensure the closure logic does not trigger while the user is dragging an icon onto the panel area.

pms: bug-336185
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, JWWTSL

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot
Copy link

deepin pr auto review

Git Diff 代码审查

整体评价

这段代码修改主要是对 tray.qml 文件中的两个条件判断进行了增强,增加了对 stashedPopup.dropHover 状态的检查。这是一个相对简单但可能有重要意义的修改。

详细审查

1. 语法逻辑

  • 修改在两处条件判断中添加了 !stashedPopup.dropHover 检查
  • 语法正确,逻辑清晰
  • 新增条件与原有条件使用 && 连接,表示所有条件必须同时满足

2. 代码质量

  • 修改遵循了现有代码风格
  • 逻辑一致性良好:两处修改都添加了相同的条件检查
  • 没有引入新的变量或函数,只是使用了已存在的 stashedPopup.dropHover 属性

3. 代码性能

  • 修改对性能影响极小,只是增加了一个布尔值的检查
  • 没有引入新的计算或复杂操作

4. 代码安全

  • 修改提高了用户体验,防止在拖拽操作时意外关闭弹出窗口
  • 没有引入明显的安全风险

改进建议

  1. 添加注释:建议为新增的 !stashedPopup.dropHover 条件添加注释,解释为什么需要这个检查,例如:

    // 防止在拖拽悬停在弹出窗口上时意外关闭
    if (!val && !Panel.contextDragging && !stashedPopup.dropHover) {
        closeStashPopupTimer.start()
    }
  2. 考虑封装:如果这个条件判断会在多处使用,可以考虑封装为一个函数或属性:

    property bool shouldClosePopup: !DDT.TraySortOrderModel.actionsAlwaysVisible && 
                                   !Panel.contextDragging && 
                                   !stashedPopup.dropHover
  3. 验证 dropHover 属性:确保 stashedPopup.dropHover 属性在所有使用前都已经正确初始化和更新,避免可能的未定义行为。

  4. 版权年份更新:注意版权年份从 "2023" 更新为 "2023-2026",确保这是有意为之的更新。

总结

这是一个简单但有意义的修改,通过增加对 stashedPopup.dropHover 状态的检查,防止在拖拽操作悬停在弹出窗口上时意外关闭弹出窗口,提高了用户体验。建议添加注释解释新增条件的用途,并确保 dropHover 属性的正确管理。

@JWWTSL
Copy link
Contributor Author

JWWTSL commented Mar 10, 2026

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Mar 10, 2026

This pr force merged! (status: behind)

@deepin-bot deepin-bot bot merged commit 21eda3d into linuxdeepin:master Mar 10, 2026
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants