From b0a1daa8e17009a1f42ad8f4fa6a0e6360abeb36 Mon Sep 17 00:00:00 2001 From: Bruno Muniz Azevedo Filho <bruno@elixxir.io> Date: Fri, 26 Aug 2022 18:00:19 -0300 Subject: [PATCH] Fix cursor moving to end of text once typing in between chars --- Sources/ChatInputFeature/ChatInputView.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/ChatInputFeature/ChatInputView.swift b/Sources/ChatInputFeature/ChatInputView.swift index 689d0842..31e5a8ae 100644 --- a/Sources/ChatInputFeature/ChatInputView.swift +++ b/Sources/ChatInputFeature/ChatInputView.swift @@ -122,7 +122,12 @@ public final class ChatInputView: UIToolbar { .map(\.text) .sink { [unowned self] in if text.textView.markedTextRange == nil { + let range = text.textView.selectedTextRange text.textView.text = $0 + + if let range = range { + text.textView.selectedTextRange = range + } } else if $0 == "" { text.textView.text = $0 } -- GitLab