on xenial help sign in
Fix regression in focus handling due to SDK change

Approved by: Michael Zanetti, PS Jenkins bot

commit2c22301afb3ee0bb790c7b61f7a38ca27ff0b954 authorAlbert Astals <albert.astals@canonical.com> dateMon 8 Sep 2014, 14:13 (12 years ago) parent7f545d07a9c869
1 file changed+13−10
qml/Dash/PageHeader.qml+13−10
qml/Dash/PageHeader.qml+13−10
@@ -64,9 +64,12 @@ Item {
6464 }
6565 }
6666
67− function closePopup() {
67+ function closePopup(keepFocus) {
6868 if (headerContainer.popover != null) {
69+ headerContainer.popover.unfocusOnDestruction = !keepFocus;
6970 PopupUtils.close(headerContainer.popover);
71+ } else if (!keepFocus) {
72+ unfocus();
7073 }
7174 }
7275
@@ -74,11 +77,8 @@ Item {
7477 if (searchHistory) {
7578 searchHistory.addQuery(searchTextField.text);
7679 }
77− if (!keepFocus) {
78− unfocus();
79− }
8080 searchTextField.text = "";
81− closePopup();
81+ closePopup(keepFocus);
8282 }
8383
8484 function unfocus() {
@@ -119,11 +119,10 @@ Item {
119119 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
120120 visible: headerContainer.showSearch
121121 onPressed: {
122− closePopup();
122+ closePopup(/* keepFocus */false);
123123 if (!searchTextField.text) {
124124 headerContainer.showSearch = false;
125125 }
126− searchTextField.focus = false;
127126 mouse.accepted = false;
128127 }
129128 }
@@ -228,7 +227,7 @@ Item {
228227
229228 onTextChanged: {
230229 if (text != "") {
231− closePopup();
230+ closePopup(/* keepFocus */true);
232231 }
233232 }
234233 }
@@ -310,8 +309,13 @@ Item {
310309 id: popover
311310 autoClose: false
312311
312+ property bool unfocusOnDestruction: false
313+
313314 Component.onDestruction: {
314315 headerContainer.popover = null;
316+ if (unfocusOnDestruction) {
317+ root.unfocus();
318+ }
315319 }
316320
317321 Column {
@@ -332,8 +336,7 @@ Item {
332336 onClicked: {
333337 searchHistory.addQuery(text);
334338 searchTextField.text = text;
335− closePopup();
336− unfocus();
339+ closePopup(/* keepFocus */false);
337340 }
338341 }
339342 }