From fb8d69dd92046e92b9f411d5110f5f6cea2b51f3 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 26 Feb 2025 08:34:39 +0200 Subject: [PATCH] Fixes #3830 - Editing messages not placing the cursor at the end of the text --- .../ComposerToolbar/View/MessageComposerTextField.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift index 86255ad0a..208c5f04f 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift @@ -139,7 +139,13 @@ private struct UITextViewWrapper: UIViewRepresentable { // https://github.com/element-hq/element-x-ios/issues/3104 textView.selectedTextRange = selection } else { - textView.selectedRange = selectedRange + // Re-setting the selected range is important when inserting pills + // but we need to not do that when entering edit mode, where the + // cursor needs to stay at the end of the text + // https://github.com/element-hq/element-x-ios/issues/3830 + if textView.selectedRange.location != text.length { + textView.selectedRange = selectedRange + } } } }