Bug 1393478 - Fix Search on home r?chutten draft
authorflyingrub <flyinggrub@gmail.com>
Tue, 29 Aug 2017 17:03:07 +0200
changeset 655047 c9c060cfc83e4de2b4d9cbb6f71888e1361f377c
parent 655046 0cd26d8f948aa4b5f34f338575f41b395b6a58aa
child 728725 d7771f40b80963910ec0402b5c846c138a3b8b6d
push id76752
push userbmo:flyinggrub@gmail.com
push dateTue, 29 Aug 2017 15:32:29 +0000
reviewerschutten
bugs1393478
milestone57.0a1
Bug 1393478 - Fix Search on home r?chutten Display when no data is found for the current filter. MozReview-Commit-ID: Fqaso0MrHUP
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1402,24 +1402,26 @@ var Search = {
 
   searchHandler(e) {
     if (this.idleTimeout) {
       clearTimeout(this.idleTimeout);
     }
     this.idleTimeout = setTimeout(() => Search.search(e.target.value), FILTER_IDLE_TIMEOUT);
   },
 
-  search(text, section = null) {
+  search(text, sectionParam = null) {
+    let section = sectionParam;
     if (!section) {
       let sectionId = document.querySelector(".category.selected").getAttribute("value");
       section = document.getElementById(sectionId);
     }
-    let noSearchResults;
+    let noSearchResults = true;
     if (section.id === "home-section") {
-      return this.homeSearch(text);
+      this.homeSearch(text);
+      return;
     } else if (section.id === "histograms-section") {
       let histograms = section.getElementsByClassName("histogram");
       noSearchResults = this.filterElements(histograms, text);
     } else if (section.id === "keyed-histograms-section") {
       let keyedElements = [];
       let keyedHistograms = section.getElementsByClassName("keyed-histogram");
       for (let key of keyedHistograms) {
         let datas = key.getElementsByClassName("histogram");
@@ -1446,17 +1448,21 @@ var Search = {
       let tables = section.querySelectorAll("table");
       for (let table of tables) {
         noSearchResults = this.filterElements(table.rows, text);
         if (table.caption) {
           table.caption.hidden = noSearchResults;
         }
       }
     }
-    this.updateNoResults(text, noSearchResults);
+
+    if (!sectionParam) { // If we are not searching in all section.
+      this.updateNoResults(text, noSearchResults);
+    }
+    return noSearchResults;
   },
 
   updateNoResults(text, noSearchResults) {
     document.getElementById("no-search-results").classList.toggle("hidden", !noSearchResults);
     if (noSearchResults) {
       let section = document.querySelector(".category.selected > span");
       let selectedTitle = section.textContent.trim();
       if (section.parentElement.id === "category-home") {
@@ -1465,30 +1471,32 @@ var Search = {
       let format = [selectedTitle, text];
       let searchStatus = bundle.formatStringFromName("noSearchResults", format, 2);
       document.getElementById("no-search-results-text").textContent = searchStatus;
     }
   },
 
   resetHome() {
     document.getElementById("main").classList.remove("search");
+    document.getElementById("no-search-results").classList.add("hidden");
     adjustHeaderState();
     Array.from(document.querySelectorAll("section")).forEach((section) => {
       section.classList.toggle("active", section.id == "home-section");
     });
   },
 
   homeSearch(text) {
     if (text === "") {
       this.resetHome();
       return;
     }
     document.getElementById("main").classList.add("search");
     let title = bundle.formatStringFromName("resultsForSearch", [text], 1);
     adjustHeaderState(title);
+    let noSearchResults = true;
     Array.from(document.querySelectorAll("section")).forEach((section) => {
       if (section.id == "home-section" || section.id == "raw-payload-section") {
         section.classList.remove("active");
         return;
       }
       section.classList.add("active");
       let sectionHidden = this.search(text, section);
       if (noSearchResults && !sectionHidden) {