on xenial help sign in
Unfocus the search text field in the dash page header when requested (LP: #1590820)

Approved by: Albert Astals Cid

commitc698d806625731818489bec3312e4a1ffc634274 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateWed 3 Aug 2016, 15:50 (10 years ago) parentba04cc9ba62a66
2 files changed+24−2
qml/Dash/DashPageHeader.qml+2−2 tests/qmltests/Dash/tst_DashContent.qml+22
qml/Dash/DashPageHeader.qml+2−2
@@ -81,7 +81,8 @@ Item {
8181 function closePopup(keepFocus, keepSearch) {
8282 if (extraPanel.visible) {
8383 extraPanel.visible = false;
84− } else if (!keepFocus) {
84+ }
85+ if (!keepFocus) {
8586 unfocus(keepSearch);
8687 }
8788 if (!keepSearch && !searchTextField.text && !root.navigationTag && searchHistory.count == 0) {
@@ -131,7 +132,6 @@ Item {
131132 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + (extraPanel ? extraPanel.height : 0) }
132133 visible: headerContainer.showSearch
133134 onPressed: {
134− extraPanel.visible = false;
135135 closePopup(/* keepFocus */false);
136136 mouse.accepted = false;
137137 }
tests/qmltests/Dash/tst_DashContent.qml+22
@@ -690,5 +690,27 @@ Item {
690690 tryCompare(pageHeader.extraPanel, "visible", false);
691691 compare(searchTextField.focus, false);
692692 }
693+
694+ function test_cancelSearch() {
695+ var dashContentList = findChild(dashContent, "dashContentList");
696+ var pageHeader = findChild(dashContentList.currentItem, "scopePageHeader")
697+ pageHeader.searchEntryEnabled = true;
698+ pageHeader.searchHistory.clear();
699+
700+ pageHeader.searchHistory.addQuery("Search1");
701+ pageHeader.searchHistory.addQuery("Search2");
702+
703+ pageHeader.triggerSearch();
704+ tryCompare(pageHeader.extraPanel, "visible", true);
705+
706+ var searchTextField = findChild(pageHeader, "searchTextField");
707+ compare(searchTextField.focus, true);
708+
709+ var cancelButton = findChild(dashContentList.currentItem, "cancelButton")
710+
711+ mouseClick(cancelButton);
712+ tryCompare(pageHeader.extraPanel, "visible", false);
713+ compare(searchTextField.focus, false);
714+ }
693715 }
694716}