Hi !
I'm asking your help today about a mysterious behavior of the navigation link coupled with the sidebar on iPadOS. First, here is my sidebar code:
List(1..<5) { _ in
NavigationLink(destination: DetailView()) {
Label("Item", systemImage: "house")
}
}
.listStyle(SidebarListStyle())
}
This view contains navigation links to display a detail view as you can see. My detail view contains another navigation link to a simple view containing a Text. Here is the code of my detail view:
Spacer()
NavigationLink(destination: Text("Hello")) {
Text("Touch me")
}
Spacer()
}
Now, let's compile this code:
The sidebar is well displayed and the first item is selected. Now let's tap the button on the detail view to trigger a navigation link inside the detail view.
When tapping the button, the navigation link is triggered as wanted, but the item in the sidebar become unselected. To compare, I would like to reproduce the iPad Music app navigation of the Album item of the sidebar. In there, you can select an album and go further in the navigation stack. And it keeps the sidebar item selected ! Can you help me to fix this issue ?
Thanks a lot !
Hello, I have the same problem. If I navigate in detail view it deselects the main navigation. Were you able to solve the problem without having to manually save the selected item?
Hello Surikata. Unfortunately, I currently unable to solve my problem... I keep looking for a solution and I'll keep you in touch if I find anything useful. I hope someone will help us here.