on xenial help sign in
Fix regression in focus handling due to SDK change
2c22301Albert Astals
qml/Dash/PageHeader.qml+13−10
@@ -64,9 +64,12 @@ Item {
64 }
64 }
65 }
65 }
66
66
67− function closePopup() {
67+ function closePopup(keepFocus) {
68 if (headerContainer.popover != null) {
68 if (headerContainer.popover != null) {
69+ headerContainer.popover.unfocusOnDestruction = !keepFocus;
69 PopupUtils.close(headerContainer.popover);
70 PopupUtils.close(headerContainer.popover);
71+ } else if (!keepFocus) {
72+ unfocus();
70 }
73 }
71 }
74 }
72
75
@@ -74,11 +77,8 @@ Item {
74 if (searchHistory) {
77 if (searchHistory) {
75 searchHistory.addQuery(searchTextField.text);
78 searchHistory.addQuery(searchTextField.text);
76 }
79 }
77− if (!keepFocus) {
78− unfocus();
79− }
80 searchTextField.text = "";
80 searchTextField.text = "";
81− closePopup();
81+ closePopup(keepFocus);
82 }
82 }
83
83
84 function unfocus() {
84 function unfocus() {
@@ -119,11 +119,10 @@ Item {
119 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
119 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
120 visible: headerContainer.showSearch
120 visible: headerContainer.showSearch
121 onPressed: {
121 onPressed: {
122− closePopup();
122+ closePopup(/* keepFocus */false);
123 if (!searchTextField.text) {
123 if (!searchTextField.text) {
124 headerContainer.showSearch = false;
124 headerContainer.showSearch = false;
125 }
125 }
126− searchTextField.focus = false;
127 mouse.accepted = false;
126 mouse.accepted = false;
128 }
127 }
129 }
128 }
@@ -228,7 +227,7 @@ Item {
228
227
229 onTextChanged: {
228 onTextChanged: {
230 if (text != "") {
229 if (text != "") {
231− closePopup();
230+ closePopup(/* keepFocus */true);
232 }
231 }
233 }
232 }
234 }
233 }
@@ -310,8 +309,13 @@ Item {
310 id: popover
309 id: popover
311 autoClose: false
310 autoClose: false
312
311
312+ property bool unfocusOnDestruction: false
313+
313 Component.onDestruction: {
314 Component.onDestruction: {
314 headerContainer.popover = null;
315 headerContainer.popover = null;
316+ if (unfocusOnDestruction) {
317+ root.unfocus();
318+ }
315 }
319 }
316
320
317 Column {
321 Column {
@@ -332,8 +336,7 @@ Item {
332 onClicked: {
336 onClicked: {
333 searchHistory.addQuery(text);
337 searchHistory.addQuery(text);
334 searchTextField.text = text;
338 searchTextField.text = text;
335− closePopup();
339+ closePopup(/* keepFocus */false);
336− unfocus();
337 }
340 }
338 }
341 }
339 }
342 }