title: How to NOT dismiss keyboard when switching between two first responder textfields in SwiftUI
body: <p>So I have a SwiftUI gesture that causes a state change to switch between two different views. In each of these views, the central component is a TextField (in this case a CocoaTextField, which was imported with SwiftUIX (a GitHub module). Each text field is a first responder, which means it goes into focus when the view presents itself. The only problem is when I switch between the two views, the keyboard dismisses itself only to re-present itself immediately after. This can be seen in the video below:</p>
  <p><a href="https://youtu.be/zTBHHuse5jA" rel="nofollow noreferrer">https://youtu.be/zTBHHuse5jA</a></p>
  <p>Not sure how to fix this glitch, any help would be much appreciated! (I've tried to remove animation but that's not the way to go)</p>
  <p>Each CocoaTextField looks like this:</p>
  <pre><code>CocoaTextField(&quot;&quot;, text: $text, onCommit: {
      UIApplication.shared.endEditing(true)
  })
  .isInitialFirstResponder(true)
  .returnKeyType(.done)
  .enablesReturnKeyAutomatically(true)
  .multilineTextAlignment(.center)
  </code></pre>