Bug 1184220 - typing in the searchbar should de-select the settings or opensearch buttons at the bottom of the search panel, r=Gijs.
authorFlorian Quèze <florian@queze.net>
Fri, 11 Sep 2015 14:18:15 +0200
changeset 295161 27893f89ee3939afce1e553a1716aaaaaa92ff7c
parent 295160 6a018a619384046f1a2cf00b60a7f573aa711a8f
child 295162 3c30e2768d9d28ea5bc0c26d4dec76e531a9162e
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1184220
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1184220 - typing in the searchbar should de-select the settings or opensearch buttons at the bottom of the search panel, r=Gijs.
browser/components/search/content/search.xml
browser/components/search/test/browser_searchbar_keyboard_navigation.js
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1138,16 +1138,20 @@
         let textbox = searchbar.textbox;
         let self = this;
         let inputHandler = function() {
           headerSearchText.setAttribute("value", textbox.value);
           let groupText;
           let isOneOffSelected =
             this.selectedButton &&
             this.selectedButton.classList.contains("searchbar-engine-one-off-item");
+          // Typing de-selects the settings or opensearch buttons at the bottom
+          // of the search panel, as typing shows the user intends to search.
+          if (this.selectedButton && !isOneOffSelected)
+            this.selectedButton = null;
           if (textbox.value) {
             self.removeAttribute("showonlysettings");
             groupText = headerSearchText.previousSibling.value +
                         '"' + headerSearchText.value + '"' +
                         headerSearchText.nextSibling.value;
             if (!isOneOffSelected)
               headerPanel.selectedIndex = 1;
           }
--- a/browser/components/search/test/browser_searchbar_keyboard_navigation.js
+++ b/browser/components/search/test/browser_searchbar_keyboard_navigation.js
@@ -147,16 +147,33 @@ add_task(function* test_arrows() {
     EventUtils.synthesizeKey("VK_UP", {});
   }
 
   is(searchPopup.selectedIndex, -1, "no suggestion should be selected");
   is(textbox.value, kUserValue,
      "the textfield value should be back to initial value");
 });
 
+add_task(function* test_typing_clears_button_selection() {
+  is(Services.focus.focusedElement, textbox.inputField,
+     "the search bar should be focused"); // from the previous test.
+  ok(!textbox.selectedButton, "no button should be selected");
+
+  EventUtils.synthesizeKey("VK_UP", {});
+  is(textbox.selectedButton.getAttribute("anonid"), "search-settings",
+     "the settings item should be selected");
+
+  // Type a character.
+  EventUtils.synthesizeKey("a", {});
+  ok(!textbox.selectedButton, "the settings item should be de-selected");
+
+  // Remove the character.
+  EventUtils.synthesizeKey("VK_BACK_SPACE", {});
+});
+
 add_task(function* test_tab() {
   is(Services.focus.focusedElement, textbox.inputField,
      "the search bar should be focused"); // from the previous test.
 
   let oneOffs = getOneOffs();
   ok(!textbox.selectedButton, "no one-off button should be selected");
 
   // Pressing tab should select the first one-off without selecting suggestions.