Nested NavigationLinks are not working properly in latest 13.0 Beta (13A5155e). If you navigate to a nested NavLink, then return one level, NavigationLink Views turn gray if touched but do not go to the destination
. See attached code.
struct ContentView: View {
var body: some View {
NavigationView {
List(1..<100) { row in
NavigationLink(destination: InnerListView()) {
Text("Row \(row)")
}
}
.navigationTitle("Outer List")
}
}
}
struct InnerListView: View {
var body: some View {
List(1..<100) { row in
NavigationLink(destination: Text("Details for row \(row)")) {
Text("Row \(row)")
}
.navigationTitle("Inner List")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I encounter the same problem and try to find where is wrong, then I remember a few days ago I have implemented this requirement and it worked, so I compare the code I have written and realize I need to add a modifier .isDetailLink(false)
after every NavigationLink
that is not linked to a final detail view. It works fine for me, hope this can help you.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List(1..<100) { row in
NavigationLink(destination: InnerListView()) {
Text("Row \(row)")
}
.isDetailLink(false)
}
.navigationTitle("Outer List")
}
}
}
struct InnerListView: View {
var body: some View {
List(1..<100) { row in
NavigationLink(destination: Text("Details for row \(row)")) {
Text("Row \(row)")
}
.isDetailLink(false)
.navigationTitle("Inner List")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}