Merge pull request #140 from writeas/fix-cursor-jump-bug

Only update the textView if it doesn't match text binding
This commit is contained in:
Angelo Stavrow 2020-11-13 15:03:26 -05:00 committed by GitHub
commit 6d8422c5f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -29,10 +29,6 @@ class PostBodyCoordinator: NSObject, UITextViewDelegate, NSLayoutManagerDelegate
}
}
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
return true
}
func textViewDidEndEditing(_ textView: UITextView) {
self.isFirstResponder = false
self.didBecomeFirstResponder = false
@ -97,7 +93,9 @@ struct PostBodyTextView: UIViewRepresentable {
}
func updateUIView(_ uiView: UITextView, context: UIViewRepresentableContext<PostBodyTextView>) {
uiView.text = text
if uiView.text != text {
uiView.text = text
}
let font = textStyle
let fontMetrics = UIFontMetrics(forTextStyle: .largeTitle)

View File

@ -112,7 +112,9 @@ struct PostTitleTextView: UIViewRepresentable {
}
func updateUIView(_ uiView: UITextView, context: UIViewRepresentableContext<PostTitleTextView>) {
uiView.text = text
if uiView.text != text {
uiView.text = text
}
let font = textStyle
let fontMetrics = UIFontMetrics(forTextStyle: .largeTitle)