You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typing within the TextField does not persist text changes. #1
Hello, hope you are well. I think I might have discovered a bug and thought I'd get your thoughts on it.
When I capture text from the camera, my @Bindings are updated successfully. However If I type within the same fields and click another element such as a button, the @Bindings are reverted back into their previous state.
I have the following code
struct ElectronicCategoryView: View {
@Binding var modelNumber: String
@Binding var serialNumber: String
var body: some View {
Group {
ScanTextField("Model Number", text: $modelNumber)
ScanTextField("Serial Number", text: $serialNumber)
}
}
}
I thought it would be as simple as adding the following code to the ScanTextField but it doesn't seem to work, presumably it's because it's not resigningFirstResponder Have you got any additional thoughts?
Hey
After 8 hours I found the solution. When you link in your Viewmodel make sure you add it by using @StateObject and not @ObservedObject and it will work.
Activity
andreaskviby commentedon Nov 25, 2021
Hey
After 8 hours I found the solution. When you link in your Viewmodel make sure you add it by using @StateObject and not @ObservedObject and it will work.