SwiftUI3 navigation link doesn't work after pop if stack size > 1

Viewed 283

SwiftUI 3 navigation link doesn't work after pop if stack size > 1

Steps to reproduce:

  1. Launch the app
  2. Tap any row in list #1
  3. Tap any row in list #2
  4. Tap Back
  5. Tap any row in list #2

Result: nothing happens, navigation link doesn't work Expected result: I should see view controller #3 again.

navigation-issue-demo-gif

Works fine in SwiftUI 2 though.

Was anyone able to make nested NavigationLinks work in Swift UI 3? I have filed an error report to Apple.

import SwiftUI

@main
struct NavigationTestApp: App {
    var body: some Scene {
        WindowGroup {
            FirstView()
        }
    }
}

struct FirstView: View {
    var body: some View {
        NavigationView {
            List {
                ForEach(0..<10) { i in
                    NavigationLink(destination: SecondView()) {
                        Text("Row \(i)")
                            .padding()
                    }
                }
            }
            .navigationTitle(Text("1"))
        }
    }
}

struct SecondView: View {
    var body: some View {
        List {
            ForEach(0..<10) { i in
                NavigationLink(destination: ThirdView()) {
                    Text("Child \(i)")
                        .padding()
                }
            }
        }
        .navigationTitle(Text("2"))
    }
}

struct ThirdView: View {
    var body: some View {
        VStack {
            Text("")
        }
        .navigationTitle(Text("3"))
    }
}

1 Answers
Related