diff --git a/Tusker/Screens/Compose/MainComposeTextView.swift b/Tusker/Screens/Compose/MainComposeTextView.swift index a65bd626..7ec9a423 100644 --- a/Tusker/Screens/Compose/MainComposeTextView.swift +++ b/Tusker/Screens/Compose/MainComposeTextView.swift @@ -149,20 +149,18 @@ struct MainComposeWrappedTextView: UIViewRepresentable { context.coordinator.didChange = textDidChange context.coordinator.uiState = uiState - if becomeFirstResponder { - DispatchQueue.main.async { + // wait until the next runloop iteration so that SwiftUI view updates have finished and + // the text view knows its new content size + DispatchQueue.main.async { + self.textDidChange(uiView) + + if becomeFirstResponder { // calling becomeFirstResponder during the SwiftUI update causes a crash on iOS 13 uiView.becomeFirstResponder() // can't update @State vars during the SwiftUI update becomeFirstResponder = false } } - - // wait until the next runloop iteration so that SwiftUI view updates have finished and - // the text view knows its new content size - DispatchQueue.main.async { - self.textDidChange(uiView) - } } func makeCoordinator() -> Coordinator {