Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in macOS picker when selecting FilePickerFileType.All #104

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal class MacOSFilePicker: PlatformFilePicker {
}

// Set file extensions
if (type !is FilePickerFileType.Folder) {
if (type !is FilePickerFileType.Folder && type !is FilePickerFileType.All) {
val extensions =
if (type is FilePickerFileType.Extension)
type.extensions
Expand All @@ -99,9 +99,15 @@ internal class MacOSFilePicker: PlatformFilePicker {
}
.flatten()
.distinct()
val items = extensions.map { Foundation.nsString(it) }
val nsData = Foundation.invokeVarArg("NSArray", "arrayWithObjects:", *items.toTypedArray())
Foundation.invoke(openPanel, "setAllowedFileTypes:", nsData)

val items = extensions
.map { Foundation.nsString(it) }
.take(256)

if (items.isNotEmpty()) {
val nsData = Foundation.invokeVarArg("NSArray", "arrayWithObjects:", *items.toTypedArray())
Foundation.invoke(openPanel, "setAllowedFileTypes:", nsData)
}
}

// Open the file picker
Expand Down