Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): persist cleared drafts when leaving the foreground #32621

ClosedwSedlacek(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/32621/headopened View on GitHub

Showing 5 changed files with 45 additions and 0 deletions (loading 2).

x
0 of 5 viewed, 5 left
9 additions and 0 deletionsapps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swiftModified
View file
@@ -834,6 +834,15 @@
​
func readState() -> [String: Any] {
+ // Commit an active IME composition now, while the send reads the draft. Left
+ // marked, it is committed when the send blurs the editor, before the cleared
+ // draft reaches this view, and that commit's change event refills the draft.
+ if textView.markedTextRange != nil {
+ isApplyingControlledValue = true
+ textView.unmarkText()
+ isApplyingControlledValue = false
+ emitTextChange()
+ }
let selection = sourceSelection()
return [
"value": value,
22 additions and 0 deletionsapps/mobile/modules/t3-composer-editor/tests/ios/main.swiftModified
View file
@@ -108,6 +108,28 @@
​
+// Send flush commits marked text before the snapshot, so a later blur has nothing to refill.
+do {
+ let view = makeEditor("hello ")
+ view.editor.selectedRange = NSRange(location: 6, length: 0)
+ view.editor.setMarkedText("wor", selectedRange: NSRange(location: 3, length: 0))
+ check(view.editor.markedTextRange != nil, "Harness could not start a composition")