Bug 481293 - The context menu of the selectable label opens at wrong position
Summary: The context menu of the selectable label opens at wrong position
Status: RESOLVED FIXED
Alias: None
Product: kdeplasma-addons
Classification: Unmaintained
Component: Picture of the Day (other bugs)
Version First Reported In: master
Platform: openSUSE Linux
: NOR minor
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2024-02-13 14:33 UTC by Fushan Wen
Modified: 2024-10-28 09:24 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fushan Wen 2024-02-13 14:33:50 UTC
SUMMARY
QQuickMenu::popup(QQuickItem *menuItem) opens the menu based on the size of its parent and its size, and when all menu items are invisible, ListView calculates its contentHeight based on an assumed average size (100), so the menu doesn't open at the right position for the first time.


STEPS TO REPRODUCE
1. Right click on any selectable label which only has one line
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 6.
KDE Frameworks Version: 
Qt Version: 6.6.1

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2024-02-13 15:12:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/370
Comment 2 Fushan Wen 2024-02-16 22:58:54 UTC
Git commit 3c64f731aa115372964fff2756d3d874953526ae by Fushan Wen.
Committed on 16/02/2024 at 22:56.
Pushed by fusionfuture into branch 'master'.

Menu: fix TextFieldContextMenu opening at wrong position

QQuickMenu places the menu based on the size of its parent and its size,
but when all menu items are invisible, the ListView in Menu.qml calculates its
contentHeight based on an assumed average size (100),
which causes the menu height to become excessively huge when there are
many invisible menu items, so when repositioning the menu will be placed
at a wrong position.

This uses childrenRect.height to only include visible items.
FIXED-IN: 6.0

M  +5    -3    org.kde.desktop/Menu.qml

https://invent.kde.org/frameworks/qqc2-desktop-style/-/commit/3c64f731aa115372964fff2756d3d874953526ae
Comment 3 Bug Janitor Service 2024-02-22 12:14:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/374
Comment 4 Fushan Wen 2024-02-23 13:53:10 UTC
Git commit 7b0d7e49b4a52166549f7a36687f91d4417f77f2 by Fushan Wen.
Committed on 23/02/2024 at 13:53.
Pushed by fusionfuture into branch 'master'.

autotests: test TextFieldContextMenu

Setting TapHandler's longPressThreshold to 0 will disable the longPressed signal since Qt 6.6.2, which breaks the text context menu again. This adds a test to make sure the menu can be opened, and catch potential regressions caused by upstream changes in the future.
CCQTBUG: https://bugreports.qt.io/browse/QTBUG-119132

M  +10   -0    kirigami-plasmadesktop-integration/autotests/CMakeLists.txt
A  +82   -0    kirigami-plasmadesktop-integration/autotests/TextFieldContextMenuTest.cpp     [License: LGPL(v2.1+)]
A  +19   -0    kirigami-plasmadesktop-integration/autotests/TextFieldContextMenuTest.qml     [License: MIT]
M  +3    -16   kirigami-plasmadesktop-integration/autotests/animationspeedmodifiertest.cpp
A  +37   -0    kirigami-plasmadesktop-integration/autotests/common.h     [License: LGPL(v2.1+)]

https://invent.kde.org/frameworks/qqc2-desktop-style/-/commit/7b0d7e49b4a52166549f7a36687f91d4417f77f2
Comment 5 Bug Janitor Service 2024-10-27 21:14:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1652
Comment 6 Akseli Lahtinen 2024-10-28 09:24:30 UTC
Git commit 94b0513ec9ebb32c0df6edbef53b19c8ef11064f by Akseli Lahtinen.
Committed on 28/10/2024 at 09:24.
Pushed by akselmo into branch 'master'.

SelectableLabel: Use onPressedChanged

OnTapped does not immediately show the context menu when label is
rightclicked, breaking QQC2 CI in the process. OnTapped shows the context
menu *after* right click is released.

This changes it to be similar to other elements we have like TextField
where right click brings the context menu immediately, instead of on
right click button release.

We utilize onPressedChanged, then check if pressed is true, to pop up the
context menu immediately.

M  +1    -1    src/controls/SelectableLabel.qml

https://invent.kde.org/frameworks/kirigami/-/commit/94b0513ec9ebb32c0df6edbef53b19c8ef11064f