Skip to content

fix(wasm): Don't double the download file extension - #25672

Open
mikernet wants to merge 3 commits into
unoplatform:masterfrom
mikernet:dev/mikernet/wasm-download-extension
Open

mikernet wants to merge 3 commits into
unoplatform:masterfrom
mikernet:dev/mikernet/wasm-download-extension

Conversation

@mikernet

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25671

PR Type:

🐞 Bugfix

What changed? 🚀

When the browser has no File System Access API (Firefox, Safari, Brave and others), FileSavePicker falls back to the download picker. That fallback always appended the first FileTypeChoices extension to SuggestedFileName, so Report.pdf with a .pdf choice was downloaded as Report.pdf.pdf.

The download picker now follows the rule that the File System Access API path (FileSavePicker.ts) and the Android picker already follow: a name that already ends with one of the FileTypeChoices extensions (case-insensitive) is kept as is, with its own casing. Otherwise the first extension of the first choice is appended, as before.

SuggestedFileName FileTypeChoices Before After
Report.pdf PDF: .pdf Report.pdf.pdf Report.pdf
Report.PDF PDF: .pdf Report.PDF.pdf Report.PDF
Report.txt PDF: .pdf; Text: .txt, .text Report.txt.pdf Report.txt
Report.text PDF: .pdf; Text: .txt, .text Report.text.pdf Report.text
Report PDF: .pdf Report.pdf Report.pdf
Report.txt PDF: .pdf Report.txt.pdf Report.txt.pdf
(empty) PDF: .pdf <GUID>.pdf <GUID>.pdf

A name whose extension none of the choices has (Report.txt with only a PDF choice) still gets the first choice's extension appended, as on the File System Access API path and on Android. What the WinUI picker does with such a name isn't documented, so that case is unchanged.

When SuggestedSaveFile is set, the download picker still returns it, unchanged.

The new Given_FileSavePicker_Download runtime tests run on Skia WebAssembly only. They pick a file with the download picker and check its name. The picker returns its file without showing anything, so the tests run unattended. I ran them locally (SamplesApp browserwasm, headless Chrome). Without the fix, all four cases fail (Report.pdf.pdf, Report.PDF.pdf, Report.txt.pdf, Report.text.pdf). With the fix, all four pass.

PR Checklist ✅

Copilot AI balanced review requested due to automatic review settings October 24, 2026 01:31
@github-actions github-actions Bot added the platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform label Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix matches the requested behavior and has targeted regression coverage, with only a nonblocking test-metadata nit remaining.

1 open issue
What changed in this PR

Fixes #25671 by preventing the WebAssembly download fallback from duplicating a recognized file extension, aligning it with the existing native-picker path.

Changes:

  • Preserves suggested names ending in any allowed extension, using case-insensitive matching.
  • Retains first-extension appending when no allowed extension matches.
  • Adds four unattended Skia WebAssembly regression cases.
File Description
src/​Uno.WinRT/​Storage/​Pickers/​FileSavePicker.wasm.cs Checks allowed extensions before appending the default extension.
src/​Uno.UI.RuntimeTests/​Windows/​Storage/​Pickers/​Given_FileSavePicker_Download.cs Tests extension preservation, including casing and alternate choices.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 24, 2026 01:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrowly scoped fix matches the reported requirements, and the regression tests cover the changed behavior with no identified blocking issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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

Labels

platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WASM] FileSavePicker download fallback doubles the extension of SuggestedFileName

2 participants