'SwiftUI: Focusing on TextField selects text

When programmatically focusing a TextField, the entire text gets selected. How can place the cursor at the end of the existing text without selecting it?

enter image description here

Code:

@State var userName = "User Name"
@FocusState var isFocused

var body: some View {
    VStack {
        Button("Focus") {
            isFocused = true
        }
        TextField("", text: $userName)
            .focused($isFocused)
    }
    .padding(40)
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source