Bug 1363743 - Redirect to general pane if search result is empty r?mconley
MozReview-Commit-ID: L4M3lPtWMKz
--- a/browser/components/preferences/in-content-new/preferences.js
+++ b/browser/components/preferences/in-content-new/preferences.js
@@ -146,32 +146,38 @@ function telemetryBucketForCategory(cate
function onHashChange() {
gotoPref();
}
function gotoPref(aCategory) {
let categories = document.getElementById("categories");
const kDefaultCategoryInternalName = "paneGeneral";
+ const kDefaultCategory = "general";
let hash = document.location.hash;
let category = aCategory || hash.substr(1) || kDefaultCategoryInternalName;
let breakIndex = category.indexOf("-");
// Subcategories allow for selecting smaller sections of the preferences
// until proper search support is enabled (bug 1353954).
let subcategory = breakIndex != -1 && category.substring(breakIndex + 1);
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();
+ } else if (!gSearchResultsPane.searchInput.value) {
+ // Something tried to send us to the search results pane without
+ // a query string. Default to the General pane instead.
+ category = kDefaultCategoryInternalName;
+ document.location.hash = kDefaultCategory;
}
// 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) {