title: SwiftUI List onTapGesture covered NavigationLink
body: <p>I want to hide keyboard when tapped the list background, but onTapGesture will cover NavigationLink. Is this a bug or have a better solution?</p>
  <pre><code>struct ContentView: View {
      @State var text: String = &quot;&quot;
      
      var body: some View {
          NavigationView {
              List {
                  NavigationLink(&quot;NextPage&quot;, destination: Text(&quot;Page&quot;))
                  
                  TextField(&quot;Placeholder&quot;, text: $text)
              }
              .onTapGesture {
                  
                  // hide keyboard...
                  UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
              }
          }
      }
  }
  </code></pre>
  <p>Thanks!</p>
  <blockquote>
  <p>update</p>
  </blockquote>
  <p>Thanks to asperi, and I found an alternative way: just put it in section header. As for style, we should create a custom ButtonStyle for NavigationLink.</p>
  <p>Here is an example of using InsetGroupedListStyle.</p>
  <pre><code>struct ContentView: View {
      @State var text: String = &quot;&quot;
      
      var body: some View {
          NavigationView {
              List {
                  Section(
                      header: NavigationLink(destination: Text(&quot;Page&quot;)) {
                          HStack {
                              Text(&quot;NextPage&quot;)
                                  .font(.body)
                                  .foregroundColor(Color.primary)
                              
                              Spacer()
                              
                              Image(systemName: &quot;chevron.forward&quot;)
                                  .imageScale(.large)
                                  .font(Font.caption2.bold())
                                  .foregroundColor(Color(UIColor.tertiaryLabel))
                              
                          }
                          .padding(.vertical, 12)
                          .padding(.horizontal)
                      }
                      .textCase(nil)
                      .buttonStyle(CellButtonStyle())
                      .clipShape(RoundedRectangle(cornerRadius: 10))
                      .padding(.horizontal, -16)
                  ) {}
                  
                  TextField(&quot;Placeholder&quot;, text: $text)
                  
              }.listStyle(InsetGroupedListStyle())
              .onTapGesture {
                  
                  // hide keyboard...
                  UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
              }
          }
      }
  }
  
  struct CellButtonStyle: ButtonStyle {
      func makeBody(configuration: Configuration) -&gt; some View {
          configuration.label
              .background(
                  configuration.isPressed
                      ? Color(UIColor.systemGray5)
                      : Color(UIColor.secondarySystemGroupedBackground)
              )
      }
  }
  </code></pre>