Post

Replies

Boosts

Views

Activity

.autocorrectionDisabled() not updating with @State variable
Using 'true' or 'false' works as expected and disables Auto Correction: TextEditor(text: $input) .autocorrectionDisabled(true) But when replacing true with a State variable, only the initial value is used. When the state value changes to 'false', the behavior of autocorrect in the TextEditor doesn't re-enable auto correction. Here's a simple View to test out: struct ContentView: View { @State var input = "" @State var autocorrectionDisabled = true var body: some View { VStack { TextEditor(text: $input) .autocorrectionDisabled(autocorrectionDisabled) .font(.headline) Button("Toggle Auto Correction") { autocorrectionDisabled.toggle() print("autocorrectionDisabled: \(autocorrectionDisabled)") } .padding() } .padding() } } Finally, the value was validated via the print() statement output: autocorrectionDisabled: false autocorrectionDisabled: true autocorrectionDisabled: false autocorrectionDisabled: true I'm running this on a physical device with iOS 15 as its our oldest supported target. I'm interested to hear others' results and ideas about how to work around this.
1
0
389
Mar ’24