In a SwiftUI
app, I need to set the focus on a TextField
and bring the keyboard automatically, in standard Swift this would be done with:
field.becomeFirstResponder()
But this does not seem to exist in SwiftUI
.
I found a work around here.
But, my field uses :onCommit; which is not in the sample code.
What is the way to set the :onCommit functionality when using UIViewRepresentable
?
There is an open-source project for your needs, at https://github.com/mobilinked/MbSwiftUIFirstResponder