Skip to content

Instantly share code, notes, and snippets.

@jamiebuilds
Last active June 14, 2023 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiebuilds/4731be0aa643774a71e4543a572f753f to your computer and use it in GitHub Desktop.
Save jamiebuilds/4731be0aa643774a71e4543a572f753f to your computer and use it in GitHub Desktop.
showSaveDialog without filters bug
let { app, dialog } = require('electron')
app.whenReady().then(async () => {
// case 1: without filters (BUG)
{
let { canceled, filePath } = await dialog.showSaveDialog({
defaultPath: "change-me.txt",
})
if (canceled) return
await dialog.showMessageBox({
message: `Selected file path (without filters): ${filePath}`
})
}
// case 2: with filters (OK)
{
let { canceled, filePath } = await dialog.showSaveDialog({
defaultPath: "change-me.txt",
filters: [{ name: "Text Files", extensions: ["txt"] }]
})
if (canceled) return
await dialog.showMessageBox({
message: `Selected file path (with filters): ${filePath}`
})
}
})
{
"name": "dangerous-hill-rain-7reyd",
"productName": "dangerous-hill-rain-7reyd",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "Jamie",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "25.1.0"
}
}
@jamiebuilds-signal
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment