Skip to content

fix: move TapHandler outside MouseArea to fix event handling#1528

Merged
wjyrich merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-353605
Mar 24, 2026
Merged

fix: move TapHandler outside MouseArea to fix event handling#1528
wjyrich merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-353605

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Mar 24, 2026

Moved the TapHandler from inside the MouseArea to be a direct child of the NotifyItem. This change resolves event handling conflicts where the TapHandler was not receiving taps properly due to being nested within the MouseArea. The TapHandler is now positioned after the MouseArea in the QML structure, ensuring it can properly capture tap events for expanding notifications when enabled.

Log: Fixed notification expansion not working when clicking on certain areas

Influence:

  1. Test clicking on notification items to ensure they expand correctly
  2. Verify that notifications with enableDismissed=false can be expanded via tap
  3. Test keyboard navigation with Enter/Return keys still works for expansion
  4. Verify that dismissed notifications (enableDismissed=true) cannot be expanded
  5. Check that focus handling works correctly when tapping notifications

fix: 将 TapHandler 移出 MouseArea 以修复事件处理

将 TapHandler 从 MouseArea 内部移动到 NotifyItem 的直接子元素。此更改解 决了事件处理冲突,由于 TapHandler 嵌套在 MouseArea 内导致无法正确接收点
击事件的问题。现在 TapHandler 在 QML 结构中位于 MouseArea 之后,确保在启 用时能够正确捕获用于展开通知的点击事件。

Log: 修复了点击某些区域时通知无法展开的问题

Influence:

  1. 测试点击通知项以确保它们能正确展开
  2. 验证 enableDismissed=false 的通知可以通过点击展开
  3. 测试键盘导航,确保 Enter/Return 键仍能用于展开
  4. 验证已关闭的通知(enableDismissed=true)无法展开
  5. 检查点击通知时的焦点处理是否正常工作

PMS: BUG-353605

Summary by Sourcery

Bug Fixes:

  • Resolve missed tap events that prevented certain notifications from expanding when clicked, while preserving keyboard-based expansion behavior.

Moved the TapHandler from inside the MouseArea to be a direct child of
the NotifyItem. This change resolves event handling conflicts where the
TapHandler was not receiving taps properly due to being nested within
the MouseArea. The TapHandler is now positioned after the MouseArea
in the QML structure, ensuring it can properly capture tap events for
expanding notifications when enabled.

Log: Fixed notification expansion not working when clicking on certain
areas

Influence:
1. Test clicking on notification items to ensure they expand correctly
2. Verify that notifications with enableDismissed=false can be expanded
via tap
3. Test keyboard navigation with Enter/Return keys still works for
expansion
4. Verify that dismissed notifications (enableDismissed=true) cannot
be expanded
5. Check that focus handling works correctly when tapping notifications

fix: 将 TapHandler 移出 MouseArea 以修复事件处理

将 TapHandler 从 MouseArea 内部移动到 NotifyItem 的直接子元素。此更改解
决了事件处理冲突,由于 TapHandler 嵌套在 MouseArea 内导致无法正确接收点
击事件的问题。现在 TapHandler 在 QML 结构中位于 MouseArea 之后,确保在启
用时能够正确捕获用于展开通知的点击事件。

Log: 修复了点击某些区域时通知无法展开的问题

Influence:
1. 测试点击通知项以确保它们能正确展开
2. 验证 enableDismissed=false 的通知可以通过点击展开
3. 测试键盘导航,确保 Enter/Return 键仍能用于展开
4. 验证已关闭的通知(enableDismissed=true)无法展开
5. 检查点击通知时的焦点处理是否正常工作

PMS: BUG-353605
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 24, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Moves the notification expansion TapHandler out of the inner MouseArea to become a direct child of NotifyItem, resolving event-handling conflicts so tap-to-expand works correctly while preserving keyboard expansion behavior.

Sequence diagram for tap-to-expand notification after TapHandler relocation

sequenceDiagram
    actor User
    participant QtInputSystem
    participant TapHandler
    participant NotifyItem

    User->>QtInputSystem: Tap on notification area
    QtInputSystem->>TapHandler: Deliver left button tap
    TapHandler->>TapHandler: Check enabled (!root.enableDismissed)
    alt enabled is true
        TapHandler->>NotifyItem: forceActiveFocus()
        TapHandler->>NotifyItem: expand()
    else enabled is false (enableDismissed is true)
        TapHandler-->>NotifyItem: No action (tap ignored)
    end
Loading

Class diagram for updated OverlapNotify QML hierarchy

classDiagram
    class NotifyItem {
        bool enableDismissed
        +forceActiveFocus()
        +expand()
    }

    class MouseArea {
        // existing click handling (unchanged)
        +onPressed
        +onReleased
        +onClicked
    }

    class TapHandler {
        bool enabled
        Qt.MouseButtons acceptedButtons
        +onTapped()
    }

    NotifyItem *-- MouseArea : contains
    NotifyItem *-- TapHandler : contains

    TapHandler : enabled = !root.enableDismissed
    TapHandler : acceptedButtons = Qt.LeftButton
    TapHandler : onTapped => root.forceActiveFocus()
    TapHandler : onTapped => root.expand()

    class KeysHandler {
        +onEnterPressed()
        +onReturnPressed()
    }

    NotifyItem *-- KeysHandler : key events

    KeysHandler : onEnterPressed => root.expand()
    KeysHandler : onReturnPressed => root.expand()
Loading

File-Level Changes

Change Details Files
Refactor TapHandler used for expanding notifications to sit alongside, rather than inside, the MouseArea so it can reliably receive tap events.
  • Removed the TapHandler definition from inside the MouseArea block that manages hover and click behavior.
  • Added an equivalent TapHandler as a direct child of NotifyItem, positioned after the MouseArea in the QML hierarchy.
  • Preserved the TapHandler configuration (enabled condition using enableDismissed, acceptedButtons filter, and focus/expand logic in onTapped).
  • Kept keyboard-based expansion shortcuts (Enter/Return key handlers) unchanged inside the MouseArea.
panels/notification/center/OverlapNotify.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 reviewed your changes and they look great!


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.

@wjyrich wjyrich requested a review from 18202781743 March 24, 2026 08:53
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, wjyrich

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

@wjyrich wjyrich merged commit 0b9cab0 into linuxdeepin:master Mar 24, 2026
10 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