-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG - When using TextView in Form #26
Comments
For anyone interested - I encountered this as well, and the only fix I found was explicitly setting isEditing as state variable on my View, so that it would remember value, but not reset every time: // This state property is actually never used by this view, and serves as a storage of editing state for text view.
@State private var isEditing: Bool = true
var body: some View {
VStack {
TextView(text: $model.text, isEditing: $isEditing)
TextField("Placeholder", text: $model.textForTextfield)
}
} This seems like a small design flaw, since TextView should remember it's state, but what happens view hierarchy changes for any reason(editing textfield is one of them), TextView may be recreated by SwiftUI, and if you passed |
@DenTelezhkin Thank you for your solution! |
Hey, sorry for not making this clear. I should have mentioned in the README that it is not possible to set a constant Binding variable for isEditing, and it must be set on the view so that it isn't recreated. So I wouldn't call it a workaround, but instead a necessary thing to do. |
Hi,
I want to use the TextView in a Form, but it always jumps to the textview when the user is typing something into other Form-TextFields. That mades the TextView unusable.
Cheers,
Jonas
The text was updated successfully, but these errors were encountered: