From 0011dfa17523b201237ad6495f80a11e546d130d Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Mon, 20 Jul 2026 18:11:35 +0200 Subject: [PATCH] fix(apple): make "Choose files" work on iOS/macOS < 27 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The send flow stacked two .fileImporter modifiers on the same view (one for files, one for folders). On iOS/macOS before 27, SwiftUI can't have two presentation modifiers of the same kind on one view — the second shadows the first, so toggling the files importer presented nothing and "Choose files" appeared to do nothing. macOS/iOS 27 changed presentation handling, which is why it worked there. Collapse the two importers into a single .fileImporter that switches its allowedContentTypes and allowsMultipleSelection based on whether a file or folder pick is pending. Behavior is unchanged on 27 and now works on 26 and earlier. --- apple/VniDrop/Platform/PlatformPickers.swift | 29 ++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apple/VniDrop/Platform/PlatformPickers.swift b/apple/VniDrop/Platform/PlatformPickers.swift index 7d70465..9ecb917 100644 --- a/apple/VniDrop/Platform/PlatformPickers.swift +++ b/apple/VniDrop/Platform/PlatformPickers.swift @@ -31,20 +31,27 @@ struct SendPickers: ViewModifier { @ObservedObject var model: SendModel func body(content: Content) -> some View { + // A single .fileImporter, switched between files and folders. Stacking two + // .fileImporter modifiers on one view silently breaks on iOS/macOS < 27: + // the second shadows the first, so "Choose files" never presents. content .fileImporter( - isPresented: Binding(get: { model.pendingFilePick }, set: { model.pendingFilePick = $0 }), - allowedContentTypes: [.item], - allowsMultipleSelection: true + isPresented: Binding( + get: { model.pendingFilePick || model.pendingFolderPick }, + set: { presented in + if !presented { + model.pendingFilePick = false + model.pendingFolderPick = false + } + } + ), + allowedContentTypes: model.pendingFolderPick ? [.folder] : [.item], + allowsMultipleSelection: !model.pendingFolderPick ) { result in - handleShareSelection(result, isDirectory: false) - } - .fileImporter( - isPresented: Binding(get: { model.pendingFolderPick }, set: { model.pendingFolderPick = $0 }), - allowedContentTypes: [.folder], - allowsMultipleSelection: false - ) { result in - handleShareSelection(result, isDirectory: true) + let isDirectory = model.pendingFolderPick + model.pendingFilePick = false + model.pendingFolderPick = false + handleShareSelection(result, isDirectory: isDirectory) } }