Closed marioradonic closed 9 months ago
@marioradonic How did you rule out this behavior in vanilla SwiftUI? If I use a vanilla observable object instead of a store I can reproduce the exact same behavior:
class Model: ObservableObject {
@Published var text = "" {
didSet {
if text == "123" {
text = ""
}
}
}
}
struct ContentView: View {
@ObservedObject var model = Model()
var body: some View {
VStack {
Text(model.text)
TextField("Title", text: $model.text).textFieldStyle(.plain)
}
}
}
Because this appears to be a vanilla SwiftUI behavior and not a bug in TCA, I'm going to convert to a discussion, where workarounds may be discussed.
Description
In the case where BindingState is updated directly in the action that updated it the TextField value is not updated. Tested with SCA 1.6.0 on iOS17 where it happens, and iOS16 where it doesn't happen.
Minimal reproducible example:
Checklist
main
branch of this package.Expected behavior
In the above example I would expect both Text and TextField values to reset to empty string if I type in "123".
Actual behavior
The value of the Text updates, but the value of the TextField stays "123".
https://github.com/pointfreeco/swift-composable-architecture/assets/4158737/a6ac8bb7-7975-48fd-8ed7-caccb17bde45
Steps to reproduce
No response
The Composable Architecture version information
1.6.0
Destination operating system
iOS 17
Xcode version information
15.2
Swift Compiler version information