diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index 46a4990a5224..883a85e30361 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -327,13 +327,24 @@ window.onload = function () { // onchange handler to be re-called without having to go via the file // picker. if (!aElem.skipClick) { + // Attempts to reopen the picker immediately might fail because the + // focus may not have switched back on some platform, so explicitly + // wait for focus here. + if (!this.ownerDocument.hasFocus()) { + let input = this; + this.ownerDocument.addEventListener("focus", (e) => { + input.click(); + }, { once: true }); + return; + } this.click(); } - } else { - let filename1 = this.filename1; - delete this.filename1; - updateAboutMemoryFromTwoFiles(filename1, file.mozFullPath); + return; } + + let filename1 = this.filename1; + delete this.filename1; + updateAboutMemoryFromTwoFiles(filename1, file.mozFullPath); } );