Bug 1367349 - Remove all tooltips after clicking on a preferences category. r=mconley
authorEvan Tseng <evan@tseng.io>
Fri, 26 May 2017 15:16:54 +0800
changeset 410166 2109d6a6d1c8f69cee5674a216b42fccf09ff2a2
parent 410091 c552b68a1c94a677bd05102543db5fca68b5012a
child 410167 b98b73c139ebfd184ae52c3da7191ae37601d996
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1367349
milestone55.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 1367349 - Remove all tooltips after clicking on a preferences category. r=mconley MozReview-Commit-ID: 5qO7oOKH0LM
browser/components/preferences/in-content-new/findInPage.js
browser/components/preferences/in-content-new/preferences.js
--- a/browser/components/preferences/in-content-new/findInPage.js
+++ b/browser/components/preferences/in-content-new/findInPage.js
@@ -187,24 +187,17 @@ var gSearchResultsPane = {
    * Shows or hides content according to search input
    *
    * @param String event
    *    to search for filted query in
    */
   searchFunction(event) {
     let query = event.target.value.trim().toLowerCase();
     this.findSelection.removeAllRanges();
-
-    // Remove all search tooltips that were created
-    let searchTooltips = Array.from(document.querySelectorAll(".search-tooltip"));
-    for (let searchTooltip of searchTooltips) {
-      searchTooltip.parentElement.classList.remove("search-tooltip-parent");
-      searchTooltip.remove();
-    }
-    this.listSearchTooltips = [];
+    this.removeAllSearchTooltips();
 
     let srHeader = document.getElementById("header-searchResults");
 
     if (query) {
       // Showing the Search Results Tag
       gotoPref("paneSearchResults");
 
       this.searchResultsCategory.hidden = false;
@@ -365,10 +358,22 @@ var gSearchResultsPane = {
     let tooltipRect = searchTooltip.getBoundingClientRect();
     let parentRect = currentNode.parentElement.getBoundingClientRect();
 
     let offSet = (anchorRect.width / 2) - (tooltipRect.width / 2);
     let relativeOffset = anchorRect.left - parentRect.left;
     offSet += relativeOffset > 0 ? relativeOffset : 0;
 
     searchTooltip.style.setProperty("left", `${offSet}px`);
+  },
+
+  /**
+   * Remove all search tooltips that were created.
+   */
+  removeAllSearchTooltips() {
+    let searchTooltips = Array.from(document.querySelectorAll(".search-tooltip"));
+    for (let searchTooltip of searchTooltips) {
+      searchTooltip.parentElement.classList.remove("search-tooltip-parent");
+      searchTooltip.remove();
+    }
+    this.listSearchTooltips = [];
   }
 }
--- a/browser/components/preferences/in-content-new/preferences.js
+++ b/browser/components/preferences/in-content-new/preferences.js
@@ -161,16 +161,17 @@ function gotoPref(aCategory) {
   if (subcategory) {
     category = category.substring(0, breakIndex);
   }
   category = friendlyPrefCategoryNameToInternalName(category);
   if (category != "paneSearchResults") {
     gSearchResultsPane.searchInput.value = "";
     gSearchResultsPane.searchResultsCategory.hidden = true;
     gSearchResultsPane.findSelection.removeAllRanges();
+    gSearchResultsPane.removeAllSearchTooltips();
   }
 
   // Updating the hash (below) or changing the selected category
   // will re-enter gotoPref.
   if (gLastHash == category && !subcategory)
     return;
   let item = categories.querySelector(".category[value=" + category + "]");
   if (!item) {