Bug 1480541 - Remove em-dash from search string dropdown text when the search query is empty. r=mak
authorDrew Willcoxon <adw@mozilla.com>
Wed, 08 Aug 2018 19:52:59 +0000
changeset 480955 78f22251dd11e53e3fa18e89c28cf314824f8ea3
parent 480954 534420d993a5494bbc31cb8687928fff3f444fe9
child 480956 275951bb69743b4517f6dc5c6a2943195cda80f6
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1480541
milestone62.0
Bug 1480541 - Remove em-dash from search string dropdown text when the search query is empty. r=mak Differential Revision: https://phabricator.services.mozilla.com/D2898
browser/base/content/browser.css
toolkit/content/widgets/autocomplete.xml
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -638,16 +638,25 @@ html|input.urlbar-input[textoverflow]:no
 }
 
 /* Only show the "Search with" label on hover or selection. */
 #PopupAutoCompleteRichResult > richlistbox > richlistitem:not([selected]):not(:hover) > .ac-action[actiontype=searchengine],
 #PopupAutoCompleteRichResult > richlistbox > richlistitem:not([selected]):not(:hover) > .ac-separator[actiontype=searchengine] {
   display: none;
 }
 
+/* Hide the em-dash separator between the search query description (.ac-title)
+   and the "Search with Foo" description (.ac-url) if the search query is the
+   empty string.  Also hide .ac-title itself because it has a margin-inline-end;
+   alternatively we would need to remove that margin in this case. */
+#PopupAutoCompleteRichResult > richlistbox > richlistitem.emptySearchQuery > .ac-separator,
+#PopupAutoCompleteRichResult > richlistbox > richlistitem.emptySearchQuery > .ac-title {
+  display: none;
+}
+
 #PopupAutoCompleteRichResult > richlistbox > richlistitem > .ac-site-icon {
   margin-inline-start: 0;
 }
 
 /* For action items in a noactions popup, show the URL text and hide the action
    text and type icon. */
 #PopupAutoCompleteRichResult[noactions] > richlistbox > richlistitem.overridable-action > .ac-url {
   display: -moz-box;
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1838,17 +1838,17 @@
             // Treat autofills as visiturl actions.
             action = {
               type: "visiturl",
               params: { url: title },
             };
           }
 
           this.removeAttribute("actiontype");
-          this.classList.remove("overridable-action");
+          this.classList.remove("overridable-action", "emptySearchQuery");
 
           // If the type includes an action, set up the item appropriately.
           if (initialTypes.has("action") || action) {
             action = action || this._parseActionUrl(originalUrl);
             this.setAttribute("actiontype", action.type);
 
             switch (action.type) {
             case "switchtab": {
@@ -1905,16 +1905,21 @@
                     [searchSuggestion.substring(idx + searchQuery.length), ""],
                   ];
                 } else {
                   pairs = [
                     [searchSuggestion, ""],
                   ];
                 }
               } else {
+                // Add the emptySearchQuery class if the search query is the
+                // empty string.  We use it to hide .ac-separator in CSS.
+                if (!searchQuery) {
+                  this.classList.add("emptySearchQuery");
+                }
                 pairs = [
                   [searchQuery, ""],
                 ];
               }
               let interpStr = pairs.map((pair, i) => `%${i + 1}$S`).join("");
               title = this._generateEmphasisPairs(interpStr, pairs);
 
               // If this is a default search match, we remove the image so we