matrix-org / matrix-rich-text-editor

Matrix Rich Text Editor
https://matrix-org.github.io/matrix-rich-text-editor/
Apache License 2.0
83 stars 19 forks source link

iOS: re-rendering RTE will make the composer not interactable #930

Closed Velin92 closed 5 months ago

Velin92 commented 5 months ago

This issue is what causes: https://github.com/element-hq/element-x-ios/issues/2364

The issue is caused by the fact that the makeUIView function is not instantiating the view, but is actually just taking the current textView reference in the WysiwygViewModel.

Since on El-X when rotating the screen and switching from a split view to a stack view and viceversa, we regenerate the view, but we keep the same object models to restore their states, what happens is that the new re-rendered SwiftUI view embedding the text view is reusing the instance from the previous view hierarchy, causing it to break its frame.

The makeUIView should actually be the one responsible of instantiating the UIKit view since its responsible of managing the view in the view hierarchy (even the documentation specifies that this function should be the one responsible of instantiating the view object in the first place). We might need to re-architecture a bit the iOS side of RTE to allow remove the depency that has been created between the view model and the UIKit text view.