Bug 1758730 - Ensure no errors or warning show on search engine prefs; r=Standard8

The live language reloading triggers code that will run that assumes the view
is visible, when in fact it may not be on the dom. This fixes that. In addition
it fixes the error where the engine tries to update after it has been removed.

Differential Revision: https://phabricator.services.mozilla.com/D141685
This commit is contained in:
Greg Tatum 2022-03-28 19:08:49 +00:00
parent 521ea00689
commit c2f751983d

View file

@ -484,10 +484,17 @@ var gSearchPane = {
remove(aEngine) {
let index = gEngineView._engineStore.removeEngine(aEngine);
if (!gEngineView.tree) {
// Only update the selection if it's visible in the UI.
return;
}
gEngineView.rowCountChanged(index, -1);
gEngineView.invalidate();
gEngineView.selection.select(Math.min(index, gEngineView.rowCount - 1));
gEngineView.ensureRowIsVisible(gEngineView.currentIndex);
document.getElementById("engineList").focus();
},
@ -652,12 +659,9 @@ EngineStore.prototype = {
let engineToUpdate = this._engines.findIndex(
e => e.originalEngine == newEngine
);
if (engineToUpdate == -1) {
console.error("Could not find engine to update");
return;
}
if (engineToUpdate != -1) {
this.engines[engineToUpdate] = this._cloneEngine(newEngine);
}
},
moveEngine(aEngine, aNewIndex) {