Revert "Attempted fix for #2653 - Reset the TextView delegates on every update call"

This reverts commit 9b9deb7dcd7c28c4171912ebb68375c1ecec9a11.
This commit is contained in:
Stefan Ceriu 2024-04-23 16:25:52 +03:00
parent d949b17448
commit 2378bb6466

View File

@ -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<UITextViewWrapper>) {
// 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