Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): sent messages no longer stay in the iOS composer after IME input #22843

Closednabettu(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/22843/headopened View on GitHub

Showing 1 changed file with 12 additions and 5 deletions.

x
0 of 1 viewed, 1 left
12 additions and 5 deletionsapps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swiftModified
View file
@@ -820,12 +820,19 @@
​
private func applyControlledDocument(force: Bool = false) {
// Rebuilding the attributed string tears down an active IME composition.
- // Skip while marked text exists; committing the composition sends a new
- // value from JS, and that update rebuilds, keeping any skipped force.
+ // While JS only echoes the text being composed, defer the rebuild until the
+ // composition commits. A different value is a deliberate replacement, such
+ // as send clearing the draft: it must win, or committing the composition
+ // later emits the sent text back into the draft.
if textView.markedTextRange != nil {
- hasDeferredForcedRebuild = hasDeferredForcedRebuild || force
- updatePlaceholderVisibility()
- return
+ if textView.serializedText() == value {
+ hasDeferredForcedRebuild = hasDeferredForcedRebuild || force
+ updatePlaceholderVisibility()
+ return
+ }
+ isApplyingControlledValue = true
+ textView.unmarkText()
+ isApplyingControlledValue = false
let shouldForce = force || hasDeferredForcedRebuild
let currentSource = textView.serializedText()