Skip to content
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

[Bug]: showSaveDialog without filters, changing name on windows drops extension #38794

Open
3 tasks done
jamiebuilds-signal opened this issue Jun 14, 2023 · 6 comments
Open
3 tasks done
Labels
25-x-y bug 🪲 component/dialog has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@jamiebuilds-signal
Copy link

Preflight Checklist

Electron Version

25.1.0

What operating system are you using?

Windows

Operating System Version

Windows 10, version 19041.1415

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

const { filePath } = await dialog.showSaveDialog({ defaultPath: "change-me.txt" })
// presented as "change-me" -- change to "updated-name"
console.log(filePath) // >> "updated-name.txt"

Actual Behavior

const { filePath } = await dialog.showSaveDialog({ defaultPath: "change-me.txt" })
// presented as "change-me" -- change to "updated-name"
console.log(filePath) // >> "updated-name" (no extension)

Testcase Gist URL

https://gist.github.com/jamiebuilds/4731be0aa643774a71e4543a572f753f

Additional Information

  • It's not always possible to create a filter for every possible file extension you could be saving
  • It's difficult to deal with paths like .tar.gz in user land
@deermichel
Copy link
Contributor

IMO this is intended behavior on Windows. If you save a file with type All Files, that extension can be anything. The effect becomes even more obvious when you enable "show file name extensions". I agree this is cumbersome, but the solution might be to verify/append the extension in your code as needed.

@deermichel deermichel added platform/windows component/dialog status/reviewed A maintainer made an initial review but not reproduced the issue 25-x-y has-repro-gist Issue can be reproduced with code at https://gist.github.com/ and removed status/reviewed A maintainer made an initial review but not reproduced the issue labels Jun 15, 2023
@jamiebuilds-signal
Copy link
Author

I'm not sure what the expected behavior for Windows users would be if it were being appended.

  • What happens if they provide their own extension that wasn't intended? file.mov -> file.mp4 or file.jpeg -> file.wrong
  • What should be presented if you have multiple extensions? file.tar.gz or file.html.md
    • Right now if you pass file.tar.gz the prompt shows file.tar, should you trim that off completely?
  • What happens if they used an alias of the file extension .jpeg -> .jpg or .js -> .mjs

One option is to ignore anything they enter as a file extension: https://gist.github.com/jamiebuilds/dbb1d7464e944a1b275df642cadd3aa1

I guess I don't know how that would come across to different windows users. If someone typed in their own file extension, would they expect that to be respected?

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@jamiebuilds-signal
Copy link
Author

bump

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@jamiebuilds-signal
Copy link
Author

bump

@codebytere codebytere added the status/confirmed A maintainer reproduced the bug or agreed with the feature label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
25-x-y bug 🪲 component/dialog has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
No open projects
Status: Unsorted Items
Development

No branches or pull requests

3 participants