aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-08-05 21:23:45 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-08-19 13:46:35 +0200
commit1a5a0a591c35dcf498a232a802087683f2244ecb (patch)
tree266f381faef196310faac61e229293dae38443df /tests
parent64230bf97c18297f45bd5d7ccf99b510c8a612bd (diff)
Prevent against re-entering prepareExitTransition after a focus change
When a popup is hidden, then it will trigger a prepareExitTransition which can cause the active focus to be lost. If the popup's visibility is tied to that fact then it can retrigger the transition which means the active focus does not go back to where it should. Therefore, we check if hadActiveFocusBeforeExitTransition is false before going through that process as then it will only be called the first time the popup is hidden. Pick-to: 5.15 Fixes: QTBUG-85884 Change-Id: I68054aeb48447617b4235ce6467514a17f1073ba Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_dialog.qml36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_dialog.qml b/tests/auto/controls/data/tst_dialog.qml
index 1bfffc1d..79053c13 100644
--- a/tests/auto/controls/data/tst_dialog.qml
+++ b/tests/auto/controls/data/tst_dialog.qml
@@ -411,4 +411,40 @@ TestCase {
button.clicked()
compare(buttonSpy.count, 1)
}
+
+ Component {
+ id: qtbug85884
+ ApplicationWindow {
+ property alias focusItemActiveFocus: item.activeFocus
+ property alias focusDialogVisible: dialog.visible
+ visible: true
+ Item {
+ id: item
+ focus: true
+ }
+ Dialog {
+ id: dialog
+ focus: true
+ visible: false
+ onActiveFocusChanged: {
+ if (!activeFocus)
+ visible = false
+ }
+ }
+ }
+ }
+
+ function test_focusLeavingDialog(data) {
+ var window = createTemporaryObject(qtbug85884, testCase)
+ verify(window)
+ tryCompare(window, "focusItemActiveFocus", true)
+
+ window.focusDialogVisible = true
+ tryCompare(window, "focusDialogVisible", true)
+ tryCompare(window, "focusItemActiveFocus", false)
+
+ window.focusDialogVisible = false
+ tryCompare(window, "focusDialogVisible", false)
+ tryCompare(window, "focusItemActiveFocus", true)
+ }
}