forked from zelo72/mastodon-ios
fix: cursor jumping when entering text before non-ascii char in share extension (#395)
This commit is contained in:
parent
6b5328946d
commit
852b91912d
|
@ -54,6 +54,9 @@ public struct StatusEditorView: UIViewRepresentable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateUIView(_ textView: UITextView, context: Context) {
|
public func updateUIView(_ textView: UITextView, context: Context) {
|
||||||
|
// preserve currently selected text range to prevent cursor jump
|
||||||
|
let currentlySelectedRange = textView.selectedRange
|
||||||
|
|
||||||
// update content
|
// update content
|
||||||
// textView.attributedText = attributedString
|
// textView.attributedText = attributedString
|
||||||
textView.text = string
|
textView.text = string
|
||||||
|
@ -66,6 +69,9 @@ public struct StatusEditorView: UIViewRepresentable {
|
||||||
viewDidAppear = false
|
viewDidAppear = false
|
||||||
textView.becomeFirstResponder()
|
textView.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// restore selected text range
|
||||||
|
textView.selectedRange = currentlySelectedRange
|
||||||
}
|
}
|
||||||
|
|
||||||
public func makeCoordinator() -> Coordinator {
|
public func makeCoordinator() -> Coordinator {
|
||||||
|
|
Loading…
Reference in New Issue