title: Pop to root view using Tab Bar in SwiftUI
body: <p>Is there any way to pop to root view by tapping the Tab Bar like most iOS apps, in SwiftUI?</p>
  <p>Here's an <a href="https://i.stack.imgur.com/RBEvL.gif" rel="noreferrer">example</a> of the expected behavior.</p>
  <p><a href="https://i.stack.imgur.com/RBEvL.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/RBEvL.gif" alt="enter image description here" /></a></p>
  <p>I've tried to programmatically pop views using <code>simultaneousGesture</code> as follow:</p>
  <pre><code>import SwiftUI
  
  
  struct TabbedView: View {
      @State var selection = 0
      @Environment(\.presentationMode) var presentationMode
      var body: some View {
                  TabView(selection: $selection) {
              RootView()
                  .tabItem {
                      Image(systemName: &quot;house&quot;)
                      .simultaneousGesture(TapGesture().onEnded{
                          self.presentationMode.wrappedValue.dismiss()
                          print(&quot;View popped&quot;)
                      })
              }.tag(0)
                  
              Text(&quot;&quot;)
                  .tabItem {
                      Image(systemName: &quot;line.horizontal.3&quot;)
              }.tag(1)
          }
      }
  }
  
  struct RootView: View {
      var body: some View{
          NavigationView{
              NavigationLink(destination:SecondView()){
          Text(&quot;Go to second view&quot;)
              }
          }
      }
  }
  
  struct SecondView: View {
      var body: some View{
          Text(&quot;Tapping the house icon should pop back to root view&quot;)
      }
  }
  </code></pre>
  <p>But seems like those gestures were ignored.</p>
  <p>Any suggestions or solutions are greatly appreciated</p>