Bug 1424469 - The Downloads view in the Library window doesn't get focus when opened. r=mak
We have to keep track of the focused element while remove the richlistbox element temporarily.
MozReview-Commit-ID: AePydUyyUS7
--- a/browser/components/downloads/content/allDownloadsViewOverlay.js
+++ b/browser/components/downloads/content/allDownloadsViewOverlay.js
@@ -424,21 +424,25 @@ DownloadsPlacesView.prototype = {
// Hack for bug 836283: reset xbl fields to their old values after the
// binding is reattached to avoid breaking the selection state
let xblFields = new Map();
for (let key of Object.getOwnPropertyNames(this._richlistbox)) {
let value = this._richlistbox[key];
xblFields.set(key, value);
}
+ let oldActiveElement = document.activeElement;
let parentNode = this._richlistbox.parentNode;
let nextSibling = this._richlistbox.nextSibling;
parentNode.removeChild(this._richlistbox);
this._richlistbox.prepend(this.batchFragment);
parentNode.insertBefore(this._richlistbox, nextSibling);
+ if (oldActiveElement && oldActiveElement != document.activeElement) {
+ oldActiveElement.focus();
+ }
for (let [key, value] of xblFields) {
this._richlistbox[key] = value;
}
},
onDownloadAdded(download, { insertBefore } = {}) {
let shell = new HistoryDownloadElementShell(download);