Bug 454778

Summary: The regexp check for shortcuts MnemonicData detection is not sufficient
Product: [Frameworks and Libraries] frameworks-qqc2-desktop-style Reporter: ratijas <me>
Component: generalAssignee: Marco Martin <notmart>
Status: ASSIGNED ---    
Severity: normal CC: ahiemstra, kde, nate, noahadvs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description ratijas 2022-06-02 22:13:28 UTC
SUMMARY
This code is problematic:

    Shortcut {
        //in case of explicit & the button manages it by itself
        enabled: !(RegExp(/\&[^\&]/).test(controlRoot.text))

It does not handle even what it's directly supposed to: an ampersand but not a double ampersand.
This snippet is duplicated across several controls. It should be fixed by rewriting into native (C++) code.

STEPS TO REPRODUCE
1. console.log(!(RegExp(/\&[^\&]/).test("Yaha && ha!")))

OBSERVED RESULT
false

EXPECTED RESULT
true

ADDITIONAL INFORMATION
Affected components are:

- Button.qml
- CheckBox.qml
- MenuBarItem.qml
- MenuItem.qml
- RadioButton.qml
- Switch.qml
- TabButton.qml
- ToolButton.qml
Comment 1 Bug Janitor Service 2023-02-27 02:24:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/241