SwiftUI iOS 15: Nested navigation link isActive not observing change

I am currently facing an issue in iOS 15 when dismissing a nested NavigationLink.

Here is a little code snippet:

struct ContentView: View {
  var body: some View {
    NavigationView {
      NavigationLink {
        View1()
      } label: {
        Text("Some link")
      }

    }
  }
}

struct View1: View {
   
  @State var isActive = false
   
  var body: some View {
    NavigationLink("View2", isActive: $isActive) {
      View2(dismiss: $isActive)
    }
  }
}

struct View2: View {
   
  @Environment(\.presentationMode) var presentationMode
  @Binding var dismiss: Bool
   
  var body: some View {
    VStack {
      Text("View2")
      Button {
        presentationMode.wrappedValue.dismiss() //this works
      } label: {
        Text("dismiss via presentationMode")
      }
       
      Button {
        dismiss = false //this does not work
      } label: {
        Text("dismiss via binding")
      }
    }
  }
}

As you can see, in View2 i have got two buttons which actually should both dismiss the NavigationLink.

However only the button "dismiss via presentationMode" will actually dismiss. When clicking on the second button "dismiss via binding", the value in View1 (isActive) is going to change, however the binding in the NavigationLink is not observing the change.

This code worked fine in iOS 14

Is this a known issue?

I could have reproduced the issue you described. Whether it is a known issue or not, you should better send a bug report. Many apps made of SwiftUI may depend on this behavior.

Yes indeed. Just submitted a bug report.

SwiftUI iOS 15: Nested navigation link isActive not observing change
 
 
Q