Bug 472784

Summary: Automatically close MenuDialog when a menu item is clicked
Product: [Frameworks and Libraries] frameworks-kirigami Reporter: Jack Hill <jackhill3103>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: me, nate, notmart
Priority: NOR    
Version First Reported In: Master   
Target Milestone: Not decided   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Jack Hill 2023-07-29 22:00:44 UTC
SUMMARY
This is standard behaviour for menus, and should be implemented here. Currently we are required to manually `menuDialog.close()` at the end of the action's `onTriggered` signal, like this:

    Kirigami.Action {
        id: myAction
        onTriggered: { myFunc(); menuDialog.close() }
    }

The problem with this is it means we cannot use this action in other contexts. For example we may want a Kirigami.MenuDialog on mobile devices and a QQC2.Menu on desktop. I should be able to just plug the same action into both components, but instead I have to define two near-identical actions to deal with MenuDialog.

STEPS TO REPRODUCE
1. Open Kirigami Gallery and navigate to the Dialogues page
2. Open the MenuDialog component
3. Click a list item

OBSERVED RESULT
Item is clicked, menu is still open

EXPECTED RESULT
Item is clicked, menu is closed

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20230724
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.10
Kernel Version: 6.4.4-1-default (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2023-09-11 18:38:58 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1244
Comment 2 ratijas 2023-09-12 21:04:04 UTC
Git commit a9b55a46f3cd941bcf85c6bbf63aeda30a4963ec by ivan tkachenko, on behalf of Jack Hill.
Committed on 12/09/2023 at 22:57.
Pushed by ratijas into branch 'master'.

MenuDialog: close when menu item is clicked

Co-Authored-By: ivan tkachenko <me@ratijas.tk>

M  +1    -0    autotests/CMakeLists.txt
A  +79   -0    autotests/tst_menudialog.qml     [License: LGPL(v2.0+)]
M  +2    -0    src/controls/MenuDialog.qml

https://invent.kde.org/frameworks/kirigami/-/commit/a9b55a46f3cd941bcf85c6bbf63aeda30a4963ec