[v3][darwin] Save dialog ignores `Filters` / `AddFilter()`: the file is saved without an extension
Wails version family
v3
Exact Wails version
v3.0.0-beta.26
Operating System
macOS
Description
On macOS the save dialog drops its filters. SaveFileDialogOptions.Filters and AddFilter() are stored on SaveFileDialogStruct, but macosSaveFileDialog.show() never passes them to showSaveFileDialog, so the NSSavePanel is presented with no allowed content types:
- a filename without an extension comes back as is:
SetFilename("report")withAddFilter("PDF Document", "*.pdf")returns/path/report, not/path/report.pdf; - the panel accepts any extension, whatever the filters say.
Everywhere else the filters are applied:
- the macOS open dialog passes them to
showOpenFileDialog; - the Windows save dialog sets
FileFiltersand takesDefaultExtensionfrom the first pattern; - the Linux save dialog adds them to the file chooser.
Wails v2 set the save panel's allowed content types from the filters (SaveFileDialog in WailsContext.m), so an app ported from v2 starts writing files without an extension. AddFilter() on the save dialog is documented in reference/dialogs.md without a platform note.
To Reproduce
main.go:
package main
import (
"fmt"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/events"
)
func main() {
app := application.New(application.Options{Name: "save-dialog-filters"})
app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
go func() {
path, err := app.Dialog.SaveFile().
SetFilename("report").
AddFilter("PDF Document", "*.pdf").
PromptForSingleSelection()
fmt.Printf("path=%q err=%v\n", path, err)
app.Quit()
}()
})
if err := app.Run(); err != nil {
panic(err)
}
}go run .- Press Save in the panel without touching the name field.
Expected behaviour
- Expected: the returned path ends with
report.pdf. The panel appends the extension of the first filter, as the Windows dialog does and as Wails v2 did on macOS. - Actual: the returned path ends with
report.-[NSSavePanel allowedContentTypes]of the presented panel is empty.
Screenshots
No response
Attempted Fixes
No response
System Details
# System
┌──────────────────────────────┐
| Name | MacOS |
| Version | 27.0 |
| ID | 26A428 |
| Branding | MacOS 27.0 |
| Platform | darwin |
| Architecture | arm64 |
| Apple Silicon | true |
| CPU | Apple M4 Max |
| CPU | Apple M4 Max |
| GPU | 40 cores |
| Memory | 128 GB |
└──────────────────────────────┘
# Build Environment
┌──────────────────────────────────────────────────────────────────────┐
| Wails CLI | v3.0.0-beta.24 |
| Go Version | go1.26.6 |
| -buildmode | exe |
| -compiler | gc |
| CGO_CFLAGS | |
| CGO_CPPFLAGS | |
| CGO_CXXFLAGS | |
| CGO_ENABLED | 1 |
| CGO_LDFLAGS | |
| DefaultGODEBUG | cryptocustomrand=1,tlssecpmlkem=0,urlstrictcolons=0 |
| GOARCH | arm64 |
| GOARM64 | v8.0 |
| GOOS | darwin |
└──────────────────────────────────────────────────────────────────────┘Additional context
Proposed fix: pass the filter extensions to showSaveFileDialog and set the panel's allowedContentTypes, the way showOpenFileDialog already does. PR to follow.
Source: wailsapp/wails