@@ -44,8 +44,8 @@ Item {
44 if (!searchHistory) return;
44 if (!searchHistory) return;
46 searchHistory.addQuery(searchField.text);
46 searchHistory.addQuery(searchField.text);
47 searchField.text = "";
48 searchField.text = "";
48− searchField.focus = false;
51 function unfocus() {
51 function unfocus() {
@@ -112,6 +112,8 @@ Item {
112 objectName: "searchContainer"
112 objectName: "searchContainer"
114 visible: searchEntryEnabled
114 visible: searchEntryEnabled
115+ property bool popoverShouldOpen: false
116+ property bool popoverShouldClose: false
116 property bool narrowMode: parent.width < label.contentWidth + units.gu(50)
118 property bool narrowMode: parent.width < label.contentWidth + units.gu(50)
@@ -127,6 +129,16 @@ Item {
127 else if (active && !narrowMode) "active"
129 else if (active && !narrowMode) "active"
128 else if (!active && !narrowMode) "inactive"
130 else if (!active && !narrowMode) "inactive"
133+ if (state == "active" || state == "narrowActive") {
134+ popoverShouldOpen = true;
135+ popoverShouldClose = false;
137+ popoverShouldOpen = false;
138+ popoverShouldClose = true;
130 function openPopover() {
142 function openPopover() {
131 if (searchHistory.count > 0) {
143 if (searchHistory.count > 0) {
132 searchContainer.popover = PopupUtils.open(popoverComponent, searchField,
144 searchContainer.popover = PopupUtils.open(popoverComponent, searchField,
@@ -137,10 +149,17 @@ Item {
152+ popoverShouldOpen = false;
153+ popoverShouldClose = false;
142 function closePopover() {
156 function closePopover() {
157+ if (searchContainer.popover) {
143− if (searchContainer.popover) PopupUtils.close(searchContainer.popover)
158+ PopupUtils.close(searchContainer.popover);
159+ searchContainer.popover = null;
161+ popoverShouldOpen = false;
162+ popoverShouldClose = false;
146 onActiveFocusChanged: if (!activeFocus) { searchHistory.addQuery(searchField.text) }
165 onActiveFocusChanged: if (!activeFocus) { searchHistory.addQuery(searchField.text) }
@@ -283,12 +302,12 @@ Item {
283 PropertyAction { target: primaryImage; property: "source" }
302 PropertyAction { target: primaryImage; property: "source" }
284 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
303 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
286− ScriptAction { script: searchContainer.openPopover() }
305+ ScriptAction { script: if (searchContainer.popoverShouldOpen) { searchContainer.openPopover(); } }
289 Transition {
308 Transition {
290 to: "inactive"
309 to: "inactive"
291− ScriptAction { script: searchContainer.closePopover() }
310+ ScriptAction { script: if (searchContainer.popoverShouldClose) { searchContainer.closePopover(); } }
292 NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.InOutQuad }
311 NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.InOutQuad }
293 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
312 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
@@ -299,12 +318,12 @@ Item {
299 NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.OutQuad }
318 NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.OutQuad }
300 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
319 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
302− ScriptAction { script: searchContainer.openPopover() }
321+ ScriptAction { script: if (searchContainer.popoverShouldOpen) { searchContainer.openPopover(); } }
305 Transition {
324 Transition {
306 to: "narrowInactive"
325 to: "narrowInactive"
307− ScriptAction { script: searchContainer.closePopover() }
326+ ScriptAction { script: if (searchContainer.popoverShouldClose) { searchContainer.closePopover(); } }
308 NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.OutQuad }
327 NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.OutQuad }
309 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
328 AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }