Bug 1184220 - typing in the searchbar should de-select the settings or opensearch buttons at the bottom of the search panel, r=Gijs.
☠☠ backed out by 8d4dfe0eb6c5 ☠ ☠
authorFlorian Quèze <florian@queze.net>
Fri, 11 Sep 2015 14:18:15 +0200
changeset 294730 c3f13feea4cd861d0e2a884ac521fed5ebaff59b
parent 294729 d79fb9007765485213040ea6d869d41b499de80a
child 294731 c3df6435ad5ef600e39b41b5e230e76dbb4b4bd5
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.