Reset keyboard after message sent (#299)

This commit is contained in:
ismailgulek 2022-11-08 13:04:18 +03:00 committed by GitHub
parent 05986cd785
commit 7a7680b165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -80,6 +80,7 @@ private struct UITextViewWrapper: UIViewRepresentable {
textView.returnKeyType = .default textView.returnKeyType = .default
textView.textContainer.lineFragmentPadding = 0.0 textView.textContainer.lineFragmentPadding = 0.0
textView.textContainerInset = .zero textView.textContainerInset = .zero
textView.keyboardType = .twitter
textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
@ -89,6 +90,17 @@ private struct UITextViewWrapper: UIViewRepresentable {
func updateUIView(_ textView: UITextView, context: UIViewRepresentableContext<UITextViewWrapper>) { func updateUIView(_ textView: UITextView, context: UIViewRepresentableContext<UITextViewWrapper>) {
if textView.text != text { if textView.text != text {
textView.text = text textView.text = text
if text.isEmpty {
// text cleared, probably because the written text is sent
// reload keyboard type
if textView.isFirstResponder {
textView.keyboardType = .default
textView.reloadInputViews()
textView.keyboardType = .twitter
textView.reloadInputViews()
}
}
} }
UITextViewWrapper.recalculateHeight(view: textView, result: $calculatedHeight, maxHeight: maxHeight) UITextViewWrapper.recalculateHeight(view: textView, result: $calculatedHeight, maxHeight: maxHeight)

1
changelog.d/269.bugfix Normal file
View File

@ -0,0 +1 @@
Timeline: Reset keyboard after a message is sent.