Skip to content

On macOS, the SuggestedStartLocation is not set if the FileTypeChoices Is not null #19035

@Whiletru3

Description

@Whiletru3

Describe the bug

The SuggestedStartLocation is not used by the StorageProvider window on macOS if the FileTypeChoices is set.
The SetAccessoryView in AvaloniaNative reset the directoryURL.

To Reproduce

In CatalogControl, modify the page DialogsPage.axaml.cs to set the SuggestedStartLocation :

 this.Get<Button>("SaveFilePicker").Click += async delegate
            {
                var fileTypes = GetFileTypes();
                var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var mainWindow = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime ;
                var topLevel = TopLevel.GetTopLevel(mainWindow.MainWindow);

                var saveFolder = await topLevel.StorageProvider.TryGetFolderFromPathAsync(folderPath);

                var file = await GetStorageProvider().SaveFilePickerAsync(new FilePickerSaveOptions()
                {
                    Title = "Save file",
                    FileTypeChoices = fileTypes,
                    SuggestedStartLocation = saveFolder,
                    SuggestedFileName = "FileName",
                    ShowOverwritePrompt = true
                });

Click open a file and select a folder (not the Documents one)

Then change the FileTypes combo to another value than None
And select Save a file. It will remain in the folder you selected in the Open a file

Expected behavior

If a SuggestedStartLocation is set, we need to go in this folder even if the filetypes is set.

Avalonia version

11.2.8, 11.3.1

OS

macOS

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions