Bug 1424469 - The Downloads view in the Library window doesn't get focus when opened. r=mak, a=RyanVM
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 30 Jan 2018 14:38:25 +0000
changeset 454663 e83f82bb996219e9e64e05d17d489ba4d9d63f64
parent 454662 7cefe9877e46f2eefab2a8169777755b96252743
child 454664 3d51ba1a7c3fdffd5f44540038f11def9832fc96
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, RyanVM
bugs1424469
milestone59.0
Bug 1424469 - The Downloads view in the Library window doesn't get focus when opened. r=mak, a=RyanVM We have to keep track of the focused element while we 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);