fix: adjust initial webContents focus calculation (#29204)
* fix: adjust initial webContents focus calculation * fix: active window check on mac * fix: about:blank focus behavior * chore: add spec Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
This commit is contained in:
parent
014bdc9f8a
commit
77297f37a3
10 changed files with 70 additions and 28 deletions
|
@ -20,20 +20,6 @@ BrowserWindow.prototype._init = function (this: BWT) {
|
|||
nativeSetBounds.call(this, bounds, ...opts);
|
||||
};
|
||||
|
||||
// Sometimes the webContents doesn't get focus when window is shown, so we
|
||||
// have to force focusing on webContents in this case. The safest way is to
|
||||
// focus it when we first start to load URL, if we do it earlier it won't
|
||||
// have effect, if we do it later we might move focus in the page.
|
||||
//
|
||||
// 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.
|
||||
if (this.webContents._initiallyShown) {
|
||||
this.webContents.once('load-url' as any, function (this: WebContents) {
|
||||
this.focus();
|
||||
});
|
||||
}
|
||||
|
||||
// Redirect focus/blur event to app instance too.
|
||||
this.on('blur', (event: Event) => {
|
||||
app.emit('browser-window-blur', event, this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue