Fixed that focusTextField may gets called during view update resulting in 'undefined behavior'
This commit is contained in:
parent
0baa74484b
commit
3d11614921
|
@ -91,10 +91,12 @@ struct UIKitTextField: UIViewRepresentable {
|
||||||
uiView.text = text
|
uiView.text = text
|
||||||
|
|
||||||
if focusTextField {
|
if focusTextField {
|
||||||
uiView.focus()
|
DispatchQueue.main.async { // in very few cases focusTextField gets called during view update resulting in 'undefined behavior' -> async() fixes this
|
||||||
|
uiView.focus()
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.focusTextField = false // reset value so that it can be set again (otherwise it may never gets resetted and then updateUIView() requests focus even though already another view got the focus in the meantime)
|
self.focusTextField = false // reset value so that it can be set again (otherwise it may never gets resetted and then updateUIView() requests focus even though already another view got the focus in the meantime)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue