From 2378bb6466c987130ef4c6e79cda9a7c2b81e2cb Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Tue, 23 Apr 2024 16:25:52 +0300 Subject: [PATCH] Revert "Attempted fix for #2653 - Reset the TextView delegates on every update call" This reverts commit 9b9deb7dcd7c28c4171912ebb68375c1ecec9a11. --- .../View/MessageComposerTextField.swift | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposerTextField.swift b/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposerTextField.swift index 8909e2bf05..42ba1bc920 100644 --- a/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposerTextField.swift +++ b/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposerTextField.swift @@ -61,6 +61,8 @@ private struct UITextViewWrapper: UIViewRepresentable { // Need to use TextKit 1 for mentions let textView = ElementTextView(usingTextLayoutManager: false) textView.isMultiline = $isMultiline + textView.delegate = context.coordinator + textView.elementDelegate = context.coordinator textView.textColor = .compound.textPrimary textView.isEditable = true textView.font = font @@ -73,9 +75,6 @@ private struct UITextViewWrapper: UIViewRepresentable { textView.keyboardType = .default textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) - - textView.delegate = context.coordinator - textView.elementDelegate = context.coordinator return textView } @@ -91,14 +90,6 @@ private struct UITextViewWrapper: UIViewRepresentable { } func updateUIView(_ textView: UITextView, context: UIViewRepresentableContext) { - // Attempted fix for element-hq/element-x-ios/issues/2653 which we can't reproduce - // but it feels like the degate doesn't get called and the binding doesn't update upwards - // The textView is changed but none of the UI depending on the binding are. - if let textView = textView as? ElementTextView { - textView.delegate = context.coordinator - textView.elementDelegate = context.coordinator - } - if textView.text != text { textView.text = text