Last active
August 27, 2025 21:00
-
-
Save jjeff/3afd1a232bdd7c2595ddb2cc885dcc98 to your computer and use it in GitHub Desktop.
Electron showOpenDialog bundle bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, BrowserWindow, dialog } = require('electron/main') | |
app.whenReady().then(async () => { | |
const mainWindow = new BrowserWindow({ height: 600, width: 600 }) | |
try { | |
const { filePaths, canceled } = await dialog.showOpenDialog(mainWindow, { | |
defaultPath: app.getPath('documents'), | |
properties: ['openFile'], | |
filters: [ | |
{ | |
name: 'Rich Text Files', | |
extensions: ['rtf', 'rtfd'], | |
}, | |
], | |
message: 'Open Rich Text File', | |
}) | |
if (canceled) { | |
console.log('Dialog was canceled') | |
} else { | |
const file = filePaths[0] | |
mainWindow.loadFile(file) | |
} | |
} catch (err) { | |
console.log(err) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "electron-open-dialog-issue", | |
"productName": "electron-open-dialog-issue", | |
"description": "My Electron application description", | |
"keywords": [], | |
"main": "./main.js", | |
"version": "1.0.0", | |
"author": "Jeff Robbins", | |
"scripts": { | |
"start": "electron ." | |
}, | |
"dependencies": {}, | |
"devDependencies": { | |
"electron": "37.3.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment