From 9cff4494ab63ef4da9a5ef52d1505d9cada69b52 Mon Sep 17 00:00:00 2001 From: Francis Eytan Dortort Date: Thu, 5 Feb 2026 13:18:25 -0500 Subject: [PATCH] fix: pass parent window to showOpenDialog for proper focus Without a parent BrowserWindow reference, the native folder picker could open behind the app window or fail to appear. Use BrowserWindow.fromWebContents(event.sender) to attach it correctly. Co-Authored-By: Claude Opus 4.5 --- src/main/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 4f0de32..07ac3de 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -13,8 +13,9 @@ app.whenReady().then(() => { createContext, }) - ipcMain.handle('dialog:openDirectory', async () => { - const result = await dialog.showOpenDialog({ + ipcMain.handle('dialog:openDirectory', async (event) => { + const parentWindow = BrowserWindow.fromWebContents(event.sender) + const result = await dialog.showOpenDialog(parentWindow!, { properties: ['openDirectory', 'createDirectory'], }) if (result.canceled || result.filePaths.length === 0) return null