fix: only focus a webContents if the window was not initially hidden (#25323) (#25330)

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
This commit is contained in:
Samuel Attard
2020-09-08 00:55:46 -07:00
committed by GitHub
parent fdbd2439a6
commit fa3652a14f
4 changed files with 18 additions and 7 deletions

View File

@@ -30,9 +30,11 @@ BrowserWindow.prototype._init = function () {
// Though this hack is only needed on macOS when the app is launched from
// Finder, we still do it on all platforms in case of other bugs we don't
// know.
this.webContents.once('load-url', function () {
this.focus();
});
if (this.webContents._initiallyShown) {
this.webContents.once('load-url', function () {
this.focus();
});
}
// Redirect focus/blur event to app instance too.
this.on('blur', (event) => {