Bug 454119

Summary: Kirigami Overlay Drawers by default set the interactive policy to false on non mobile, causing escape key to not close the drawer or follow closePolicy
Product: [Frameworks and Libraries] frameworks-kirigami Reporter: Aditya Mehra <Aix.m>
Component: generalAssignee: Marco Martin <notmart>
Status: RESOLVED FIXED    
Severity: normal CC: matej.starc, nate
Priority: NOR Keywords: usability
Version: 5.94.0   
Target Milestone: Not decided   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In: 5.102
Sentry Crash Report:

Description Aditya Mehra 2022-05-21 00:04:38 UTC
SUMMARY
- Kirigami Overlay Drawers do not close when the escape key is pressed. explicitly adding the closePolicy does not seem to help either. 
- Escape Key and closePolicy only works when setting the interactive property explicitly to true in non mobile environment 
- Interactive property of the overlay drawer seems to be set to false by default on non mobile platforms or touch enabled platforms.

STEPS TO REPRODUCE:
Sample Code:
- The overlay drawer has been given a closePolicy, but does not react to escape key press unless interactive property is set to true

Kirigami.AbstractApplicationWindow {
    width: 640
    height: 480
    visible: true

    Button {
        anchors.bottom: parent.bottom
        width: parent.width
        height: Kirigami.Units.gridUnit * 2
        text: "Open Drawer"

        onClicked: {
            exampleOverlayDrawer.open()
        }
    }

    Kirigami.OverlayDrawer {
        id: exampleOverlayDrawer
        width: parent.width
        height: parent.height * 0.5
        edge: Qt.TopEdge
        closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
        dim: true
        // if this property is not set to true explicitly on non mobile platforms closePolicy does not apply and escape key is not caught
        // interactive: true 

        onOpened: {
            sampleButton.forceActiveFocus()
        }

        contentItem: Item {
            Button {
                id: sampleButton
                width: parent.width
                height: Kirigami.Units.gridUnit * 2
                text: "Close Drawer"

                background: Rectangle {
                    color: sampleButton.activeFocus ? Kirigami.Theme.highlightColor : "white"
                }

                onClicked: {
                    exampleOverlayDrawer.close()
                }
            }
        }
    }
}

SOFTWARE/OS VERSIONS
Distribution: KDE Neon
KDE Plasma Version: 5.24.80
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.3
Graphics Platform: X11
Comment 1 Matej Starc 2022-11-11 16:39:49 UTC
If I set interactive to true, it works as intended, but the Qt doc is implying that interactive sets touch gestures and not all gestures.
https://doc.qt.io/qt-6/qml-qtquick-controls2-drawer.html#interactive-prop
Comment 2 Matej Starc 2022-11-11 16:47:33 UTC
I tested this on my laptop, and it works as intended when using the touchscreen.
Comment 3 Nate Graham 2022-12-07 14:32:39 UTC
Fixed by Matej Starc with https://invent.kde.org/frameworks/kirigami/-/commit/ffd5af1e55798d784d9a6100dfb43ce73d8912f4 in Frameworks 5.102!