From 088e5924a1f9e0304fbd269635588a2c48375e2d Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 13 Nov 2020 13:36:50 -0500 Subject: [PATCH] Only update the textView if it doesn't match text binding --- iOS/PostEditor/PostBodyTextView.swift | 8 +++----- iOS/PostEditor/PostTitleTextView.swift | 4 +++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/iOS/PostEditor/PostBodyTextView.swift b/iOS/PostEditor/PostBodyTextView.swift index 3ab791e..609533e 100644 --- a/iOS/PostEditor/PostBodyTextView.swift +++ b/iOS/PostEditor/PostBodyTextView.swift @@ -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) { - uiView.text = text + if uiView.text != text { + uiView.text = text + } let font = textStyle let fontMetrics = UIFontMetrics(forTextStyle: .largeTitle) diff --git a/iOS/PostEditor/PostTitleTextView.swift b/iOS/PostEditor/PostTitleTextView.swift index 60017e8..705bcf4 100644 --- a/iOS/PostEditor/PostTitleTextView.swift +++ b/iOS/PostEditor/PostTitleTextView.swift @@ -112,7 +112,9 @@ struct PostTitleTextView: UIViewRepresentable { } func updateUIView(_ uiView: UITextView, context: UIViewRepresentableContext) { - uiView.text = text + if uiView.text != text { + uiView.text = text + } let font = textStyle let fontMetrics = UIFontMetrics(forTextStyle: .largeTitle)