Bug 1136139 - Fix collapsing of search suggestions when there are none. r=florian

This commit is contained in:
Gijs Kruitbosch 2015-04-29 15:35:00 +01:00
parent 281974e4f2
commit b9e79681db
8 changed files with 59 additions and 16 deletions

View File

@ -1149,7 +1149,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
}
else {
this.removeAttribute("showonlysettings");
tree.collapsed = false;
// Uncollapse as long as we have a tree with a view which has >= 1 row.
// The autocomplete binding itself will take care of uncollapsing later,
// if we currently have no rows but end up having some in the future
// when the search string changes
tree.collapsed = !tree.view || !tree.view.rowCount;
}
// Show the current default engine in the top header of the panel.

View File

@ -638,6 +638,7 @@
autocompletesearchparam="searchbar-history"
maxrows="10"
completeselectedindex="true"
minresultsforpopup="0"
xbl:inherits="disabled,disableautocomplete,searchengine,src,newlines">
<!--
Empty <box> to properly position the icon within the autocomplete
@ -1087,9 +1088,10 @@
let buttons = this.getSelectableButtons(aCycleEngines);
let suggestionsHidden;
if (!aSkipSuggestions && popup.hasAttribute("showonlysettings")) {
aSkipSuggestions = true;
suggestionsHidden = true;
if (!aSkipSuggestions) {
let suggestions = document.getAnonymousElementByAttribute(popup, "anonid", "tree");
suggestionsHidden = suggestions.getAttribute("collapsed") == "true";
aSkipSuggestions = suggestionsHidden;
}
// If the last suggestion is selected, DOWN selects the first button.

View File

@ -13,6 +13,7 @@ const searchIcon = document.getAnonymousElementByAttribute(searchbar, "anonid",
const goButton = document.getAnonymousElementByAttribute(searchbar, "anonid", "search-go-button");
const textbox = searchbar._textbox;
const searchPopup = document.getElementById("PopupSearchAutoComplete");
const kValues = ["long text", "long text 2", "long text 3"];
const isWindows = Services.appinfo.OS == "WINNT";
const mouseDown = isWindows ? 2 : 1;
@ -44,6 +45,37 @@ function* synthesizeNativeMouseClick(aElement) {
add_task(function* init() {
yield promiseNewEngine("testEngine.xml");
// First cleanup the form history in case other tests left things there.
yield new Promise((resolve, reject) => {
info("cleanup the search history");
searchbar.FormHistory.update({op: "remove", fieldname: "searchbar-history"},
{handleCompletion: resolve,
handleError: reject});
});
yield new Promise((resolve, reject) => {
info("adding search history values: " + kValues);
let ops = kValues.map(value => { return {op: "add",
fieldname: "searchbar-history",
value: value}
});
searchbar.FormHistory.update(ops, {
handleCompletion: function() {
registerCleanupFunction(() => {
info("removing search history values: " + kValues);
let ops =
kValues.map(value => { return {op: "remove",
fieldname: "searchbar-history",
value: value}
});
searchbar.FormHistory.update(ops);
});
resolve();
},
handleError: reject
});
});
});
// Adds a task that shouldn't show the search suggestions popup.

View File

@ -119,7 +119,7 @@ searchbar[oneoffui] .search-go-button:-moz-locale-dir(rtl) > .toolbarbutton-icon
-moz-box-align: center;
}
.search-panel-current-engine:not([showonlysettings]) {
.search-panel-current-engine {
border-bottom: 1px solid #ccc;
}
@ -131,6 +131,10 @@ searchbar[oneoffui] .search-go-button:-moz-locale-dir(rtl) > .toolbarbutton-icon
color: #666;
}
.search-panel-tree[collapsed=true] + .search-panel-header {
border-top: none;
}
.search-panel-current-input > label {
margin: 0 0 !important;
}

View File

@ -142,7 +142,7 @@ searchbar[oneoffui] .search-go-button:-moz-locale-dir(rtl) > .toolbarbutton-icon
border-radius: 4px 4px 0 0;
}
.search-panel-current-engine:not([showonlysettings]) {
.search-panel-current-engine {
border-bottom: 1px solid #ccc;
}
@ -156,6 +156,10 @@ searchbar[oneoffui] .search-go-button:-moz-locale-dir(rtl) > .toolbarbutton-icon
color: #666;
}
.search-panel-tree[collapsed=true] + .search-panel-header {
border-top: none;
}
.search-panel-current-input > label {
margin: 0 0 !important;
}

View File

@ -131,7 +131,7 @@ searchbar[oneoffui] .search-go-button:-moz-locale-dir(rtl) > .toolbarbutton-icon
-moz-box-align: center;
}
.search-panel-current-engine:not([showonlysettings]) {
.search-panel-current-engine {
border-bottom: 1px solid #ccc;
}
@ -144,6 +144,10 @@ searchbar[oneoffui] .search-go-button:-moz-locale-dir(rtl) > .toolbarbutton-icon
color: #666;
}
.search-panel-tree[collapsed=true] + .search-panel-header {
border-top: none;
}
.search-panel-current-input > label {
margin: 0 0 !important;
}

View File

@ -74,13 +74,6 @@ SuggestAutoComplete.prototype = {
finalComments = finalComments.concat(comments);
}
// If no result, add the search term so that the panel of the new UI is shown anyway.
if (!finalResults.length &&
Services.prefs.getBoolPref("browser.search.showOneOffButtons")) {
finalResults.push(results.term);
finalComments.push("");
}
// Notify the FE of our new results
this.onResultsReady(results.term, finalResults, finalComments, results.formHistoryResult);
},

View File

@ -713,9 +713,9 @@
var height = rows * bx.rowHeight;
if (height == 0)
if (height == 0) {
this.tree.setAttribute("collapsed", "true");
else {
} else {
if (this.tree.hasAttribute("collapsed"))
this.tree.removeAttribute("collapsed");