title: SwiftUI Navigation does not work as expected with 3 views when navigationLink to third view is embedded in a navigationBar button
body: <p>I'm a novice Xcode/SwiftUI developer and have been stuck on the following problem related to navigation. In the following minimum, reproducible example, I want the user to be able to navigate backwards through the app view-by-view after reaching the ThirdView as follows: ThirdView -&gt; SecondView -&gt; FirstView (or ContentView, in the example below).</p>
  <p>When the NavigationLink in the SecondView to reach the ThirdView is in the body of the SecondView, everything works as expected. (This is the SecondView code I've commented out in the example below.) However, if I move that same NavigationLink up to the navigation bar (as shown), clicking the &quot;Back to 2nd View&quot; bar button in the ThirdView does nothing. The view does not change. Is there a way to navigate from SecondView -&gt; ThirdView via a navigation link in the bar button but still be able to progress backwards from the ThirdView -&gt; SecondView, as well?</p>
  <p>I've read some question-and-answers to issues like this online that suggest that this problem is a glitch in the Xcode Simulator, but when I load the app on my device, I have the same problem.</p>
  <pre><code>struct ContentView: View {
      @State private var activeLink: Bool = false
      var body: some View {
          NavigationView {
              VStack {
                  Spacer()
                  NavigationLink(&quot;Show Second Screen&quot;,
                      destination: SecondView(active: $activeLink), isActive: $activeLink)
                  Spacer()
              }.padding()
              .navigationBarTitle(&quot;First view&quot;)
          }
      }
  }
  
  struct SecondView: View {
      @Binding var active: Bool
      @State private var thirdViewLink: Bool = false
      
      var body: some View {
          VStack {
          Spacer()
      // This works as expected but is not ideal for my purposes
       /* NavigationLink(&quot;Show Third View&quot;,
              destination: ThirdView(thirdViewActive: $thirdViewLink), isActive: $thirdViewLink) */
          Spacer()
          }.padding()
          .navigationBarTitle(&quot;Second View&quot;)
          .navigationBarBackButtonHidden(true)
          .navigationBarItems(leading: Button(&quot;Back to 1st View&quot;) {
              self.active = false
          }, trailing: NavigationLink(&quot;Show Third View&quot;,
                                      destination: ThirdView(thirdViewActive: $thirdViewLink),
                                      isActive: $thirdViewLink))
      }
  }
  
  struct ThirdView: View {
      @Binding var thirdViewActive: Bool
      var body: some View {
          VStack(spacing: 15) {
              Text(&quot;Third View&quot;)
              Spacer()
          }.padding()
          .navigationBarItems(leading: Button(&quot;Back to 2nd View&quot;) {
              self.thirdViewActive = false
          })
      }
  }
  </code></pre>