Menu: fix contentItem's interactive

The interactive property of the Menu's contentItem depends on its Menu
(control) when Window.window is valid. In the case of a fixed-height
menu, even if the contentItem's height is smaller than
Window.window.height, the interactive property of the contentItem would
be false if the menu's height is smaller than the window's height and
also smaller than its contentItem's height.

Fixes: QTBUG-93856
Pick-to: 6.2
Change-Id: If95080250c3953d4293a9e1dbcc6225d21ee034f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit d0a83e3330)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e6478662c1)
This commit is contained in:
MohammadHossein Qanbari 2023-11-13 13:44:22 +01:00 committed by Qt Cherry-pick Bot
parent c6f88a807c
commit 933ef03332
8 changed files with 40 additions and 12 deletions

View File

@ -22,8 +22,8 @@ T.Menu {
implicitHeight: contentHeight implicitHeight: contentHeight
model: control.contentModel model: control.contentModel
interactive: Window.window interactive: Window.window
? contentHeight + control.topPadding + control.bottomPadding > Window.window.height ? contentHeight + control.topPadding + control.bottomPadding > control.height
: false : false
clip: true clip: true
currentIndex: control.currentIndex currentIndex: control.currentIndex

View File

@ -26,8 +26,8 @@ T.Menu {
implicitHeight: contentHeight implicitHeight: contentHeight
model: control.contentModel model: control.contentModel
interactive: Window.window interactive: Window.window
? contentHeight + control.topPadding + control.bottomPadding > Window.window.height ? contentHeight + control.topPadding + control.bottomPadding > control.height
: false : false
clip: true clip: true
currentIndex: control.currentIndex currentIndex: control.currentIndex

View File

@ -36,8 +36,8 @@ T.Menu {
implicitHeight: contentHeight implicitHeight: contentHeight
model: control.contentModel model: control.contentModel
interactive: Window.window interactive: Window.window
? contentHeight + control.topPadding + control.bottomPadding > Window.window.height ? contentHeight + control.topPadding + control.bottomPadding > control.height
: false : false
clip: true clip: true
currentIndex: control.currentIndex currentIndex: control.currentIndex

View File

@ -35,8 +35,8 @@ T.Menu {
implicitHeight: contentHeight implicitHeight: contentHeight
model: control.contentModel model: control.contentModel
interactive: Window.window interactive: Window.window
? contentHeight + control.topPadding + control.bottomPadding > Window.window.height ? contentHeight + control.topPadding + control.bottomPadding > control.height
: false : false
clip: true clip: true
currentIndex: control.currentIndex currentIndex: control.currentIndex

View File

@ -42,8 +42,8 @@ T.Menu {
model: control.contentModel model: control.contentModel
interactive: Window.window interactive: Window.window
? contentHeight + control.topPadding + control.bottomPadding > Window.window.height ? contentHeight + control.topPadding + control.bottomPadding > control.height
: false : false
clip: true clip: true
currentIndex: control.currentIndex currentIndex: control.currentIndex

View File

@ -23,8 +23,8 @@ T.Menu {
implicitHeight: contentHeight implicitHeight: contentHeight
model: control.contentModel model: control.contentModel
interactive: Window.window interactive: Window.window
? contentHeight + control.topPadding + control.bottomPadding > Window.window.height ? contentHeight + control.topPadding + control.bottomPadding > control.height
: false : false
clip: true clip: true
currentIndex: control.currentIndex currentIndex: control.currentIndex

View File

@ -0,0 +1,27 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
import QtQuick.Window
Window {
width: 300
height: 300
property alias menu: menu
Menu {
id: menu
anchors.centerIn: parent
height: 100
visible: true
Repeater {
model: 10
delegate: MenuItem {
objectName: text
text: (index + 1)
}
}
}
}

View File

@ -1788,6 +1788,7 @@ void tst_QQuickMenu::scrollable_data()
QTest::addRow("Window") << QString::fromLatin1("windowScrollable.qml"); QTest::addRow("Window") << QString::fromLatin1("windowScrollable.qml");
QTest::addRow("ApplicationWindow") << QString::fromLatin1("applicationWindowScrollable.qml"); QTest::addRow("ApplicationWindow") << QString::fromLatin1("applicationWindowScrollable.qml");
QTest::addRow("WithPadding") << QString::fromLatin1("scrollableWithPadding.qml"); QTest::addRow("WithPadding") << QString::fromLatin1("scrollableWithPadding.qml");
QTest::addRow("FixedHeight") << QString::fromLatin1("scrollableWithFixedHeight.qml");
} }
void tst_QQuickMenu::scrollable() void tst_QQuickMenu::scrollable()