Wrap becomeFirstResponder in async dispatch

This fixes issues when we’re updating the responder chain every time SwiftUI refreshes the view, which can have unpredictable side effects.
This commit is contained in:
Angelo Stavrow 2022-12-12 07:40:11 -05:00
parent 1361ff7586
commit 6e60e0ded5
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -41,9 +41,11 @@ private struct UITextViewWrapper: UIViewRepresentable {
uiView.text = self.text
}
if uiView.window != nil, isEditing {
if uiView.window != nil && isEditing {
DispatchQueue.main.async {
uiView.becomeFirstResponder()
}
}
UITextViewWrapper.recalculateHeight(view: uiView, result: $calculatedHeight)
}