I have ObservableObject for my parent view and child view:
import Parchment
class MainViewModel: ObservableObject {
@Published var inputText = String()
init() {}
}
struct ChildView: View {
@EnvironmentObject var viewModel: MainViewModel
var body: some View {
PageView(/**/) {
TextField("", $viewModel.inputText)
}
}
}
}
I tried to put inputText in child view's ObservedObject but got no changes.
When I'm entering one letter, keyboard closes. I think that SwiftUI starts redrawing of whole page, and because of this TextField becomes inactive.
How to fix this? Maybe somehow activate TextField by force, or start keyboard?