Post

Replies

Boosts

Views

Activity

Reply to How to keep a sidebar item selected when navigation link is triggered in the detail view on iPadOS with SwiftUI?
Thank you for your answer MobileTen. Actually, looking Fruta sample code, I already tried to use selection. Here is what I got: @State private var selection: String?     var body: some View { NavigationView { List { NavigationLink(destination: DetailView(), tag: "1", selection: $selection) { Label("Item 1", systemImage: "house") } NavigationLink(destination: DetailView(), tag: "2", selection: $selection) { Label("Item 2", systemImage: "house") } NavigationLink(destination: DetailView(), tag: "3", selection: $selection) { Label("Item 3", systemImage: "house") } } .listStyle(SidebarListStyle()) }     } Once on my Detail view, here is my code: var body: some View { VStack { Spacer() NavigationLink(destination: Text("Hello")) { Text("Touch me") } Spacer() }     } But when I tap on the "Touch me" navigation link, the item in sidebar become unselected. Am I doing it right ? It's pretty weird because this behavior seems to appear only on iPadOS 15, I did not have the problem on iPadOS 14.
Nov ’21