Bug 465154 - (Regression.) GlobalDrawer{} Z-order drawn on top of descendant elements, like Controls.Menu{} and Kirigami Tooltips.
Summary: (Regression.) GlobalDrawer{} Z-order drawn on top of descendant elements, lik...
Status: REPORTED
Alias: None
Product: frameworks-kirigami
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 5.102.0
Platform: Other Linux
: NOR normal
Target Milestone: Not decided
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-02 03:50 UTC by Will Chen
Modified: 2023-05-04 22:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Tooltips are also covered. (56.66 KB, image/png)
2023-02-02 06:06 UTC, Will Chen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Will Chen 2023-02-02 03:50:23 UTC
SUMMARY

When a `GlobalDrawer{}` contains items that open a `Controls.Menu{}` on right click, and you keep repeatedly right clicking on those items to close and open that menu, eventually the `GlobalDrawer{}` will seem to gain some kind of focus and the `Menu{}` will begin to show up underneath the `GlobalDrawer{}` instead of on top of it.


STEPS TO REPRODUCE

A minimum reproducer and screenshots of the expected and broken behaviour are provided in the below repository. Check the main commit as well for a clear view of everything required:

https://invent.kde.org/intralexical/globaldrawerzorder_bug-reproducer

1. Right click on a button in a GlobalDrawer{} that opens a Menu{}.
2. When the Menu{} is open, move your mouse left or up a bit, off of the Menu{}.
3. Left or right click on either the button or the area around it to close the Menu{}.
4. Do this repeatedly.


OBSERVED RESULT

5. Eventually, the GlobalDrawer{} will seem to gain focus on click, and move to on top of the Menu{}.
6. Once this happens, all subsequent times opening the Menu{} will also show it underneath the drawer.


EXPECTED RESULT

Right-click context menu should always be shown on top of the UI elements it contextualizes.


SOFTWARE/OS VERSIONS

KDE Plasma Version: 5.26.5
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8
Comment 1 Will Chen 2023-02-02 06:06:49 UTC
Created attachment 155871 [details]
Tooltips are also covered.

This also happens to tooltips, as can be seen in Kirigami Gallery 22.12.1 when the GlobalDrawer is set to "Collapsible Sidebar Drawer" and you mouse over the "Close Sidebar" button at the bottom. (See attached screenshot.)
Comment 2 Will Chen 2023-02-02 06:24:35 UTC
Manually setting the Z-Order can fix it as a temporary workaround:

```QML
_testMenu.z = _globalDrawer.z + 1
```

At the point where it breaks, the ancestry tree of the button and the GlobalMenu{} itself changes:

```QML
let ancestry = []
let p = parent
while (p) {
    console.log(p)
    ancestry.push(p)
    p = p.parent
}

console.log(ancestry.map(x => x.toString()))
```

Working:

```Console
qml: StableCollapsibleIconButton_QMLTYPE_116(0x55b9ea241dd0)
qml: TabDelegateBase_QMLTYPE_119(0x55b9e8c99e30)
qml: QQuickItem(0x55b9e5b37300)
qml: QQuickListView(0x55b9e5b40ce0)
qml: QQuickColumnLayout_QML_151(0x55b9e5b8b450)
qml: QQuickColumnLayout(0x55b9e5a352d0)
qml: QQuickItem(0x55b9e6461f50)
qml: QQuickFlickable(0x55b9e5be8290)
qml: ScrollView_QMLTYPE_95(0x55b9e5cbca10)
qml: QQuickPopupItem(0x55b9e58600c0)
qml: QQuickRootItem(0x55b9e5913c50)
qml: [StableCollapsibleIconButton_QMLTYPE_116(0x55b9ea241dd0),TabDelegateBase_QMLTYPE_119(0x55b9e8c99e30),QQuickItem(0x55b9e5b37300),QQuickListView(0x55b9e5b40ce0),QQuickColumnLayout_QML_151(0x55b9e5b8b450),QQuickColumnLayout(0x55b9e5a352d0),QQuickItem(0x55b9e6461f50),QQuickFlickable(0x55b9e5be8290),ScrollView_QMLTYPE_95(0x55b9e5cbca10),QQuickPopupItem(0x55b9e58600c0),QQuickRootItem(0x55b9e5913c50)]
```

Broken:

```Console
qml: StableCollapsibleIconButton_QMLTYPE_116(0x55b9ea241dd0)
qml: TabDelegateBase_QMLTYPE_119(0x55b9e8c99e30)
qml: QQuickItem(0x55b9e5b37300)
qml: QQuickListView(0x55b9e5b40ce0)
qml: QQuickColumnLayout_QML_151(0x55b9e5b8b450)
qml: QQuickColumnLayout(0x55b9e5a352d0)
qml: QQuickItem(0x55b9e6461f50)
qml: QQuickFlickable(0x55b9e5be8290)
qml: ScrollView_QMLTYPE_95(0x55b9e5cbca10)
qml: QQuickPopupItem(0x55b9e58600c0)
qml: QQuickOverlay(0x55b9e59b2230) ←←← This is new.
qml: QQuickRootItem(0x55b9e5913c50)
qml: [StableCollapsibleIconButton_QMLTYPE_116(0x55b9ea241dd0),TabDelegateBase_QMLTYPE_119(0x55b9e8c99e30),QQuickItem(0x55b9e5b37300),QQuickListView(0x55b9e5b40ce0),QQuickColumnLayout_QML_151(0x55b9e5b8b450),QQuickColumnLayout(0x55b9e5a352d0),QQuickItem(0x55b9e6461f50),QQuickFlickable(0x55b9e5be8290),ScrollView_QMLTYPE_95(0x55b9e5cbca10),QQuickPopupItem(0x55b9e58600c0),QQuickOverlay(0x55b9e59b2230),QQuickRootItem(0x55b9e5913c50)]
```
Comment 3 Will Chen 2023-02-27 13:06:34 UTC
I neglected to mention this in my original report. I believe this is a recent regression. It only started happening on my main machine when I updated in January, and it does not happen, for example, in NixPkgs `23.05pre436403.ba6ba2b9009` from December 20 2022, corresponding to Kirigami2 5.101.0.

https://github.com/NixOS/nixpkgs/tree/ba6ba2b90096dc49f448aa4d4d783b5081b1cc87

```
nix-repl> pkgs.libsForQt5.kirigami2.version
"5.101.0"
```
Comment 4 Will Chen 2023-05-04 22:41:54 UTC
Seems like there are quite a few places where `.z` gets imperatively or declaratively assigned an arbitrary-but-high value:

https://invent.kde.org/search?search=z%3A&project_id=2506&group_id=1552&search_code=true&repository_ref=master
https://invent.kde.org/search?search=z+%3D&project_id=2506&group_id=1552&search_code=true&repository_ref=master

I guess the question then is why, and what changed that this didn't used to happen.

IIRC Personally I have been working around this by simply unsetting `.z` in my GlobalDrawer instance, so it's not a showstopper— I guess that would still cause a single right click event to be missed, and have no effect, when the bug and hierarchy change is triggered, though.