Post

Replies

Boosts

Views

Activity

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") } } } } }
1
0
111
2w