Only update the textView if it doesn't match text binding

This commit is contained in:
Angelo Stavrow 2020-11-13 13:36:50 -05:00
parent 539597bd5a
commit 088e5924a1
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
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)