Skip to content

Instantly share code, notes, and snippets.

@jjeff
Last active August 27, 2025 21:00
Show Gist options
  • Save jjeff/3afd1a232bdd7c2595ddb2cc885dcc98 to your computer and use it in GitHub Desktop.
Save jjeff/3afd1a232bdd7c2595ddb2cc885dcc98 to your computer and use it in GitHub Desktop.
Electron showOpenDialog bundle bug
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)
}
})
{
"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