Using this adapted code snippet from the Apple Developer Documentation,
struct ContentView: View {
@State var nameComponents = PersonNameComponents()
var body: some View {
Form {
TextField(
"Proper name",
value: $nameComponents,
format: .name(style: .medium)
)
.onSubmit {
}
.disableAutocorrection(true)
.border(.secondary)
Text(nameComponents.debugDescription)
}
}
}
It runs and works as expected on my iOS device. When I use this same code in my macOS app, it has unexpected results. The validation mechanism (likely caused by format: .name(style: .medium)
in order to bind the TextField
to a PersonNameComponents
instance, will not let me add spaces or delete all the text in the TextField
. I have to write the first name in this format: "FirstLast" and then add a space in between the t and L. Are there any ways I can fix this on macOS while still binding my TextField
to a PersonNameComponents
instance?