1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-22 06:19:03 +01:00

fix: cursor jumping when entering text before non-ascii char in share extension (#395)

This commit is contained in:
Marcus Kida 2022-04-28 21:41:13 +02:00 committed by GitHub
parent 6b5328946d
commit 852b91912d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,6 +54,9 @@ public struct StatusEditorView: UIViewRepresentable {
}
public func updateUIView(_ textView: UITextView, context: Context) {
// preserve currently selected text range to prevent cursor jump
let currentlySelectedRange = textView.selectedRange
// update content
// textView.attributedText = attributedString
textView.text = string
@ -66,6 +69,9 @@ public struct StatusEditorView: UIViewRepresentable {
viewDidAppear = false
textView.becomeFirstResponder()
}
// restore selected text range
textView.selectedRange = currentlySelectedRange
}
public func makeCoordinator() -> Coordinator {