Fixed that focusTextField may gets called during view update resulting in 'undefined behavior'
This commit is contained in:
parent
0baa74484b
commit
3d11614921
|
@ -91,6 +91,7 @@ struct UIKitTextField: UIViewRepresentable {
|
||||||
uiView.text = text
|
uiView.text = text
|
||||||
|
|
||||||
if focusTextField {
|
if focusTextField {
|
||||||
|
DispatchQueue.main.async { // in very few cases focusTextField gets called during view update resulting in 'undefined behavior' -> async() fixes this
|
||||||
uiView.focus()
|
uiView.focus()
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
@ -98,6 +99,7 @@ struct UIKitTextField: UIViewRepresentable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func addDoneButtonToKeyboard(_ textField: UITextField, _ coordinator: Coordinator) {
|
private func addDoneButtonToKeyboard(_ textField: UITextField, _ coordinator: Coordinator) {
|
||||||
coordinator.textField = textField
|
coordinator.textField = textField
|
||||||
|
|
Loading…
Reference in New Issue