From dff47263d555fa5d2b7745c0cb3b23ee1e0482fd Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Wed, 17 Jan 2024 22:35:58 +1100 Subject: [PATCH] Set default extension for save dialog file filter The code update sets the default extension to the first pattern in the save dialog file filter when options.Filters is populated. This improvement applies to Windows platform interface function for 'Save File Dialog' and provides a more intuitive user experience. --- v3/pkg/application/dialogs_windows.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/v3/pkg/application/dialogs_windows.go b/v3/pkg/application/dialogs_windows.go index 133e70da9..f3c06a81e 100644 --- a/v3/pkg/application/dialogs_windows.go +++ b/v3/pkg/application/dialogs_windows.go @@ -168,6 +168,11 @@ func (m *windowSaveFileDialog) show() (chan string, error) { Folder: defaultFolder, } + // Original PR for v2 by @almas1992: https://github.com/wailsapp/wails/pull/3205 + if len(options.Filters) > 0 { + config.DefaultExtension = strings.TrimPrefix(strings.Split(options.Filters[0].Pattern, ";")[0], "*") + } + result, err := showCfdDialog( func() (cfd.Dialog, error) { return cfd.NewSaveFileDialog(config)