Inspector List and NavigationSplitView

When using the NavigationSplitView with an inspector containing a list which has swipeActions and onDelete, item actions behave erratically.

It seems that there is a gesture conflict between the swipe action and the NavigationSplitView. Is there any modifier that could be used to force gesture focus on the inspector?


struct Animal: Hashable {
    var name : String
}

struct ContentView: View {
    
    @State private var isShowingInspector = false
    
    var body: some View {
        NavigationSplitView {
            Text("Main")
        } detail: {
            Text("Detail")
                .inspector(isPresented: $isShowingInspector) {
                    InspectorView()
                        .toolbar {
                            ToolbarItem(placement: .primaryAction) {
                                Button {
                                    isShowingInspector.toggle()
                                } label: {
                                    Label("Preferences", systemImage: "gearshape")
                                }                            }
                        }

                }
        }
    }
}

struct InspectorView: View {

    @State var animals = [
        Animal(name: "Dog"),
        Animal(name: "Cat"),
        Animal(name: "Parrot")
    ]
    @State private var selectedAnimal: Animal?

    var body: some View {
        NavigationStack {
            Text(selectedAnimal?.name ?? "Select an animal")
            
            List(selection: $selectedAnimal) {
                Section {
                    ForEach(animals, id: \.self) { animal in
                        Text(animal.name)
                            .swipeActions(edge: .leading) {
                                Button("Edit") {
                                }
                                .tint(.green)
                            }
                    }
                    .onDelete { indexSet in
                    }
                } header: {
                    Text("Animals")
                }
            }
        }
    }
}

There's no supported way for you to disable the NavigationSplitView gesture with the APIs currently available. If you'd like us to consider adding the necessary functionality, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

As a workaround you could use UISplitViewController wrapped in a UIViewControllerRepresentable and set displayModeButtonVisibility to always

Inspector List and NavigationSplitView
 
 
Q