Bug 1294531 - Use a className instead of an ID to alter the state of the search engine list to allow add-ons to add their own buttons to the page and choose the behavior that they want. r=gijs
MozReview-Commit-ID: 78VufTvjYVC
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -101,21 +101,26 @@ var gSearchPane = {
if (e.name == currentEngine)
list.selectedItem = item;
});
},
handleEvent: function(aEvent) {
switch (aEvent.type) {
case "click":
- if (aEvent.target.id != "engineChildren" && aEvent.target.id != "removeEngineButton") {
+ if (aEvent.target.id != "engineChildren" &&
+ !aEvent.target.classList.contains("searchEngineAction")) {
let engineList = document.getElementById("engineList");
// We don't want to toggle off selection while editing keyword
- // so proceed only when the input field is hidden
- if (engineList.inputField.hidden) {
+ // so proceed only when the input field is hidden.
+ // We need to check that engineList.view is defined here
+ // because the "click" event listener is on <window> and the
+ // view might have been destroyed if the pane has been navigated
+ // away from.
+ if (engineList.inputField.hidden && engineList.view) {
let selection = engineList.view.selection;
if (selection.count > 0) {
selection.toggleSelect(selection.currentIndex);
}
engineList.blur();
}
}
if (aEvent.target.id == "addEngines" && aEvent.button == 0) {
--- a/browser/components/preferences/in-content/search.xul
+++ b/browser/components/preferences/in-content/search.xul
@@ -75,16 +75,17 @@
<hbox>
<button id="restoreDefaultSearchEngines"
label="&restoreDefaultSearchEngines.label;"
accesskey="&restoreDefaultSearchEngines.accesskey;"
/>
<spacer flex="1"/>
<button id="removeEngineButton"
+ class="searchEngineAction"
label="&removeEngine.label;"
accesskey="&removeEngine.accesskey;"
disabled="true"
/>
</hbox>
<separator class="thin"/>