Bug 1424469 - The Downloads view in the Library window doesn't get focus when opened. r=mak draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 30 Jan 2018 14:38:25 +0000
changeset 748820 61c4583ae3f38f75fbf15105fc0667a33c7686bd
parent 748783 9746e0a0a81cc089ff65e30ae902864846cd1b94
push id97248
push userpaolo.mozmail@amadzone.org
push dateTue, 30 Jan 2018 14:40:02 +0000
reviewersmak
bugs1424469
milestone60.0a1
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
browser/components/downloads/content/allDownloadsViewOverlay.js
--- 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);