SelectFolderDialog opens with a file (not a folder) selected

Xojo2018r4 Mac

Bug: SelectFolderDialog sometimes opens with a file selected (not always, just sometimes).

Obviously, files are supposed to be inaccessible (greyed out) in a select folder dialog. The user can unselect the file, and then it cannot be selected. I know I can set the initial directory, but I shouldn’t have to in order to avoid this wrong behaviour. Anyone else see this happening?

Here’s my workaround:

Public Function ShowSelectFolderDialog(promptTxt as string = "Select a destination folder.", buttonCaption as string = "Select") as Folderitem // start by assigning an existing folderitem that we know is not a directory dim f As FolderItem = App.ExecutableFile while not f.Directory // accept only a directory or a nil folderitem as the result of the dialog Dim dlg As New SelectFolderDialog dlg.ActionButtonCaption = "Select" dlg.PromptText = "Select a destination folder." f = dlg.ShowModal if f = Nil then exit while wend return f End Function

Then whenever I want a select folder dialog, I use:

dim f As FolderItem = ShowSelectFolderDialog

With this workaround, if a user clicks the Select button to dismiss the dialog with the erroneous file pre-selected, the dialog just remains open, until they either cancel or click away from the selected item to a folder, or click somewhere outside the list to select the parent directory of the erroneously pre-selected file. This works on Mac, not tested on Windows. I’m away from my Windows laptop so can’t test this – anyone want to try this code on Windows?

I understand the problem you are seeing but I don’t see it on Windows 10 (Xojo 2018R4). Using the SelectFolderDialog on Windows, the only entries that appear at all are folders and shortcuts that point to folders.