https://bugs.kde.org/show_bug.cgi?id=518024

            Bug ID: 518024
           Summary: Kirigami.Icon in custom compactRepresentation absorbs
                    mouse events, blocking parent MouseArea clicks
    Classification: Plasma
           Product: plasmashell
      Version First 6.6.3
       Reported In:
          Platform: Ubuntu
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: 1.0

Product: plasmashell
Component: general
Version: 6.0.0
Severity: Normal
Keywords: plasmoid, compactRepresentation, MouseArea
Summary:  Kirigami.Icon in custom compactRepresentation absorbs mouse events,
preventing parent Item MouseArea from receiving clicks over the icon area
Description:
When implementing a custom compactRepresentation that contains a Kirigami.Icon
alongside other items (e.g. a PlasmaComponents.Label), the Kirigami.Icon
silently absorbs mouse events. This prevents the parent Item's MouseArea (with
anchors.fill: parent) from toggling the plasmoid's expanded state when clicking
over the icon area.
The KDE documentation states: "If you modify the compact representation, you
must use a MouseArea QML Item to toggle the plasmoid.expanded property."
However, even with a correctly placed MouseArea on the root Item, clicks on the
Kirigami.Icon area are absorbed and do not reach the MouseArea.
Steps to reproduce:

Create a plasmoid with a custom compactRepresentation containing a
Kirigami.Icon and a PlasmaComponents.Label inside a RowLayout
Place a MouseArea with anchors.fill: parent on the root Item
Click on the icon portion of the compact representation — the popup does not
toggle
Click on the label portion — the popup toggles correctly

Expected behaviour:
Clicking anywhere within the compact representation should toggle the plasmoid
popup, consistent with the documented MouseArea approach.
Actual behaviour:
Only the area not covered by Kirigami.Icon registers clicks. The icon area
absorbs mouse events without forwarding them.
Workaround:
Add a second MouseArea directly inside the Kirigami.Icon element in addition to
the root Item's MouseArea:
compactRepresentation: Item {
    implicitWidth: compactRow.implicitWidth + 12
    implicitHeight: compactRow.implicitHeight

    MouseArea {
        anchors.fill: parent
        onClicked: root.expanded = !root.expanded
    }

    RowLayout {
        id: compactRow
        anchors.centerIn: parent

        Kirigami.Icon {
            source: Qt.resolvedUrl("../icons/mywidget.svg")
            implicitWidth: 22
            implicitHeight: 22

            MouseArea {
                anchors.fill: parent
                onClicked: root.expanded = !root.expanded
            }
        }

        PlasmaComponents.Label {
            text: "some text"
        }
    }
}

See also bug 416311 (CompactRepresentation's MouseArea intercepts hover 
event) — related MouseArea/Kirigami.Icon interaction issue in the same 
code area, marked RESOLVED FIXED. Click event absorption appears to be 
a separate unresolved regression from the same root cause.

Plasma Version: 6.6.3
QMake version 3.1
Using Qt version 6.10.2 in /usr/lib/x86_64-linux-gnu
KDE Frameworks Version: 6.24.0-0ubuntu1 
OS: Linux (Wayland and X11)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to