2

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"))
    }
}

Nik
  • 9,063
  • 7
  • 66
  • 81
  • 1
    It is a known issue per release notes look under SwiftUI https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-15-beta-release-notes – lorem ipsum Jun 26 '21 at 18:01

1 Answers1

1

As @loremipsum said, it's a known issue

https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-15-beta-release-notes

SwiftUI Known Issues You can’t push to a third screen after popping from a third screen in the navigation stack. (79076444)

Nik
  • 9,063
  • 7
  • 66
  • 81