Merge lp:~aacid/ubuntu-ui-toolkit/fix_popup_focus_restore into lp:ubuntu-ui-toolkit/staging
- fix_popup_focus_restore
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 2155 |
Merged at revision: | 2154 |
Proposed branch: | lp:~aacid/ubuntu-ui-toolkit/fix_popup_focus_restore |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
135 lines (+34/-19) 4 files modified
src/imports/Components/Popups/1.3/PopupBase.qml (+8/-16) src/imports/Components/Popups/1.3/popupUtils.js (+6/-1) tests/unit/visual/tst_focus.13.qml (+2/-2) tests/unit/visual/tst_popups_dialog.13.qml (+18/-0) |
To merge this branch: | bzr merge lp:~aacid/ubuntu-ui-toolkit/fix_popup_focus_restore |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
ubuntu-sdk-build-bot | continuous-integration | Approve | |
Zsombor Egri | Approve | ||
Cris Dywan | Needs Fixing | ||
Review via email: mp+314156@code.launchpad.net |
Commit message
Fix saving/restoring of previous item focus for popups
You can't save the focus after the popup/dialog has been created,
at that stage the dialog has focus already,
you need to do it before creating it
Description of the change
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2153
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2153
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2153
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2153
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Cris Dywan (kalikiana) wrote : | # |
XPASS : components:
Loc: [/tmp/buildd/
PASS : components:
XFAIL : components:
Loc: [/tmp/buildd/
PASS : components:
XFAIL : components:
Loc: [/tmp/buildd/
- 2154. By Albert Astals Cid
-
Merge
- 2155. By Albert Astals Cid
-
Seems i fixed 1569979
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2154
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2154
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2154
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2154
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2154
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Zsombor Egri (zsombi) wrote : | # |
Looks good to me. Thanks for fixing!
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2155
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'src/imports/Components/Popups/1.3/PopupBase.qml' | |||
2 | --- src/imports/Components/Popups/1.3/PopupBase.qml 2016-04-13 19:32:20 +0000 | |||
3 | +++ src/imports/Components/Popups/1.3/PopupBase.qml 2017-01-10 12:23:48 +0000 | |||
4 | @@ -119,6 +119,14 @@ | |||
5 | 119 | 119 | ||
6 | 120 | /*! | 120 | /*! |
7 | 121 | \internal | 121 | \internal |
8 | 122 | The function saves the active focus for later. | ||
9 | 123 | */ | ||
10 | 124 | function __setPreviousActiveFocusItem(item) { | ||
11 | 125 | stateWrapper.prevFocus = item; | ||
12 | 126 | } | ||
13 | 127 | |||
14 | 128 | /*! | ||
15 | 129 | \internal | ||
16 | 122 | Foreground component excluded from InverseMouseArea | 130 | Foreground component excluded from InverseMouseArea |
17 | 123 | */ | 131 | */ |
18 | 124 | property Item __foreground | 132 | property Item __foreground |
19 | @@ -177,30 +185,14 @@ | |||
20 | 177 | /*! \internal */ | 185 | /*! \internal */ |
21 | 178 | onParentChanged: stateWrapper.rootItem = QuickUtils.rootItem(popupBase) | 186 | onParentChanged: stateWrapper.rootItem = QuickUtils.rootItem(popupBase) |
22 | 179 | Component.onCompleted: { | 187 | Component.onCompleted: { |
23 | 180 | stateWrapper.saveActiveFocus(); | ||
24 | 181 | stateWrapper.rootItem = QuickUtils.rootItem(popupBase); | 188 | stateWrapper.rootItem = QuickUtils.rootItem(popupBase); |
25 | 182 | } | 189 | } |
26 | 183 | 190 | ||
27 | 184 | Item { | 191 | Item { |
28 | 185 | id: stateWrapper | 192 | id: stateWrapper |
29 | 186 | property Item rootItem: QuickUtils.rootItem(popupBase) | 193 | property Item rootItem: QuickUtils.rootItem(popupBase) |
30 | 187 | |||
31 | 188 | property bool windowIsValid: typeof window != "undefined" | ||
32 | 189 | property Item prevFocus | 194 | property Item prevFocus |
33 | 190 | 195 | ||
34 | 191 | function saveActiveFocus() { | ||
35 | 192 | // 'window' context property is exposed to QML after component completion | ||
36 | 193 | // before rendering is complete, therefore a simple 'if (window)' check is | ||
37 | 194 | // not enough. | ||
38 | 195 | if (windowIsValid) { | ||
39 | 196 | prevFocus = window.activeFocusItem; | ||
40 | 197 | windowIsValidChanged.disconnect(saveActiveFocus); | ||
41 | 198 | } else { | ||
42 | 199 | // connect the function so we can save the original focus item | ||
43 | 200 | windowIsValidChanged.connect(saveActiveFocus); | ||
44 | 201 | } | ||
45 | 202 | } | ||
46 | 203 | |||
47 | 204 | function restoreActiveFocus() { | 196 | function restoreActiveFocus() { |
48 | 205 | if (prevFocus) { | 197 | if (prevFocus) { |
49 | 206 | if (prevFocus.hasOwnProperty("requestFocus")) { | 198 | if (prevFocus.hasOwnProperty("requestFocus")) { |
50 | 207 | 199 | ||
51 | === modified file 'src/imports/Components/Popups/1.3/popupUtils.js' | |||
52 | --- src/imports/Components/Popups/1.3/popupUtils.js 2016-09-15 15:53:27 +0000 | |||
53 | +++ src/imports/Components/Popups/1.3/popupUtils.js 2017-01-10 12:23:48 +0000 | |||
54 | @@ -66,6 +66,8 @@ | |||
55 | 66 | } | 66 | } |
56 | 67 | 67 | ||
57 | 68 | var popupObject; | 68 | var popupObject; |
58 | 69 | // If there's an active item, save it so we can restore it later | ||
59 | 70 | var prevFocusItem = (typeof window !== "undefined") ? window.activeFocusItem : null; | ||
60 | 69 | if (params !== undefined) { | 71 | if (params !== undefined) { |
61 | 70 | popupObject = popupComponent.createObject(rootObject, params); | 72 | popupObject = popupComponent.createObject(rootObject, params); |
62 | 71 | } else { | 73 | } else { |
63 | @@ -75,8 +77,11 @@ | |||
64 | 75 | print(popupComponent.errorString().slice(0, -1)); | 77 | print(popupComponent.errorString().slice(0, -1)); |
65 | 76 | print("PopupUtils.open(): Failed to create the popup object."); | 78 | print("PopupUtils.open(): Failed to create the popup object."); |
66 | 77 | return; | 79 | return; |
68 | 78 | } else if (popupObject.hasOwnProperty("caller") && caller) | 80 | } else if (popupObject.hasOwnProperty("caller") && caller) { |
69 | 79 | popupObject.caller = caller; | 81 | popupObject.caller = caller; |
70 | 82 | } else if (popupObject.hasOwnProperty("__setPreviousActiveFocusItem")) { | ||
71 | 83 | popupObject.__setPreviousActiveFocusItem(prevFocusItem); | ||
72 | 84 | } | ||
73 | 80 | 85 | ||
74 | 81 | // if caller is specified, connect its cleanup to the popup's close | 86 | // if caller is specified, connect its cleanup to the popup's close |
75 | 82 | // so popups will be removed together with the caller. | 87 | // so popups will be removed together with the caller. |
76 | 83 | 88 | ||
77 | === modified file 'tests/unit/visual/tst_focus.13.qml' | |||
78 | --- tests/unit/visual/tst_focus.13.qml 2016-09-19 16:40:49 +0000 | |||
79 | +++ tests/unit/visual/tst_focus.13.qml 2017-01-10 12:23:48 +0000 | |||
80 | @@ -414,13 +414,13 @@ | |||
81 | 414 | component: dialogComponent, | 414 | component: dialogComponent, |
82 | 415 | item: null, | 415 | item: null, |
83 | 416 | foreground_name: "dialogForeground", | 416 | foreground_name: "dialogForeground", |
85 | 417 | bug: "1569979" | 417 | bug: "" // this is not buggy |
86 | 418 | }, | 418 | }, |
87 | 419 | { tag: "Popover component", | 419 | { tag: "Popover component", |
88 | 420 | component: popoverComponent, | 420 | component: popoverComponent, |
89 | 421 | item: null, | 421 | item: null, |
90 | 422 | foreground_name: "popover_foreground", | 422 | foreground_name: "popover_foreground", |
92 | 423 | bug: "" // this is the only case without a bug | 423 | bug: "" // this is not buggy |
93 | 424 | }, | 424 | }, |
94 | 425 | { tag: "Dialog item", | 425 | { tag: "Dialog item", |
95 | 426 | component: null, | 426 | component: null, |
96 | 427 | 427 | ||
97 | === modified file 'tests/unit/visual/tst_popups_dialog.13.qml' | |||
98 | --- tests/unit/visual/tst_popups_dialog.13.qml 2016-06-15 13:46:51 +0000 | |||
99 | +++ tests/unit/visual/tst_popups_dialog.13.qml 2017-01-10 12:23:48 +0000 | |||
100 | @@ -47,6 +47,21 @@ | |||
101 | 47 | keyClick(Qt.Key_Escape); | 47 | keyClick(Qt.Key_Escape); |
102 | 48 | tryCompare(test, "dialogDestroyed", true, 500, "Dialog not destroyed"); | 48 | tryCompare(test, "dialogDestroyed", true, 500, "Dialog not destroyed"); |
103 | 49 | } | 49 | } |
104 | 50 | |||
105 | 51 | function test_focus_restore_ondismiss_dialog() { | ||
106 | 52 | pressMe.forceActiveFocus(); | ||
107 | 53 | |||
108 | 54 | tryCompare(window, "activeFocusItem", pressMe); | ||
109 | 55 | |||
110 | 56 | var dlg = PopupUtils.open(dialog); | ||
111 | 57 | waitForRendering(dlg); | ||
112 | 58 | |||
113 | 59 | tryCompare(window, "activeFocusItem", dlg.button); | ||
114 | 60 | |||
115 | 61 | keyClick(Qt.Key_Escape); | ||
116 | 62 | |||
117 | 63 | tryCompare(window, "activeFocusItem", pressMe); | ||
118 | 64 | } | ||
119 | 50 | } | 65 | } |
120 | 51 | 66 | ||
121 | 52 | Component { | 67 | Component { |
122 | @@ -54,10 +69,13 @@ | |||
123 | 54 | Dialog { | 69 | Dialog { |
124 | 55 | id: ahojDialog | 70 | id: ahojDialog |
125 | 56 | title: "Ahoj" | 71 | title: "Ahoj" |
126 | 72 | property alias button: closeButton | ||
127 | 57 | 73 | ||
128 | 58 | Button { | 74 | Button { |
129 | 75 | id: closeButton | ||
130 | 59 | text: "Close" | 76 | text: "Close" |
131 | 60 | onClicked: PopupUtils.close(ahojDialog) | 77 | onClicked: PopupUtils.close(ahojDialog) |
132 | 78 | focus: true | ||
133 | 61 | } | 79 | } |
134 | 62 | } | 80 | } |
135 | 63 | } | 81 | } |
FAILED: Continuous integration, rev:2153 /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-i386- gles-stable/ 1337/ /jenkins. ubuntu. com/ubuntu- sdk/job/ generic- update- mp/7321/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-i386- gles-stable/ 1337/rebuild
https:/