title: SwiftUI: Focusing on TextField selects text
body: <p>When programmatically focusing a <code>TextField</code>, the entire text gets selected. How can place the cursor at the end of the existing text without selecting it?</p>
  <p><a href="https://i.stack.imgur.com/LgBFX.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LgBFX.gif" alt="enter image description here" /></a></p>
  <p>Code:</p>
  <pre><code>@State var userName = &quot;User Name&quot;
  @FocusState var isFocused
  
  var body: some View {
      VStack {
          Button(&quot;Focus&quot;) {
              isFocused = true
          }
          TextField(&quot;&quot;, text: $userName)
              .focused($isFocused)
      }
      .padding(40)
  }
  </code></pre>