New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dialog.showSaveDialog() returns file name which doesn't include the chosen extension on Linux #21935
Comments
Hi @codebytere and @bsivanov, I'd like to attract your attention to a recent comment I made, reviving a proposal that would allow to get back the selected filter of a saveDialog that would remove the need for electron to manually append the extension to the filename if the end user omits it. Taking inspiration from what was originally proposed by @mb21, the selected filter could be an extra property on the object resolved by the Promise returned by const result = await dialog.showSaveDialog({
filters: [
{ name: 'Filter 1', extensions: ['txt', 'rtf'] },
{ name: 'Filter 2', extensions: ['doc', 'docx'] },
{ name: 'Filter 3', extensions: ['pdf'] },
],
});
// result already has the `canceled`, `filePath` and `bookmark` properties
console.log(results.canceled); // false
console.log(results.filePath); // /tmp/my-file
console.log(results.bookmark); // ''
// the proposal is to add a new property called `selectedFilter` that would contain the selected filter as provided in `options.filters`
console.log(result.selectedFilter); // { name: 'Filter 2', extensions: ['doc', 'docx'] } Would that be feasible with the way electron handles the dialogs ? |
What's strange is that the extension is considered something different than the file name. At least on Linux, the file extension is just part of the file name. So if the user saves a file with a certain file name, including an extension if they want, when getting the file name back it should include the whole file name, including the extension if present. |
Issue Details
Expected Behavior
On Linux,
dialog.showSaveDialog
method returns file name which doesn't include the extension chosen by the user.Actual Behavior
dialog.showSaveDialog
method returns file name which include the extension chosen by the user as part of the returned file name.To Reproduce
Additional Information
Moreover, there is no API available to get the chosen extension (#15254).
It seems this behavior was available at some point (#4634).
The text was updated successfully, but these errors were encountered: