From b33046cb1b8f2492dfc45590672f75a4e88f6340 Mon Sep 17 00:00:00 2001 From: purocean Date: Fri, 10 Jan 2025 15:53:33 +0800 Subject: [PATCH] fix(app): prevent focus issue by checking frame existence before handling dom-ready --- src/main/app.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/app.ts b/src/main/app.ts index a14053ed..dd60d302 100644 --- a/src/main/app.ts +++ b/src/main/app.ts @@ -610,6 +610,10 @@ if (!gotTheLock) { // fix focus issue after dialog show on Windows. webContents.on('frame-created', (_, { frame }) => { + if (!frame) { + return + } + frame.on('dom-ready', () => { frame.executeJavaScript(`if ('ctx' in window && ctx?.env?.isWindows) { window._FIX_ELECTRON_DIALOG_FOCUS ??= function () {