Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): accept iOS autocorrection before submitting #16890

Closedgmackie(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromrefs/pull/16890/headopened View on GitHub

Showing 9 changed files with 74 additions and 19 deletions (loading 6).

x
0 of 9 viewed, 9 left
3 additions and 0 deletionsapps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorModule.swiftModified
View file
@@ -124,6 +124,9 @@
AsyncFunction("blur") { (view: T3ComposerEditorView) in
view.blurEditor()
+ AsyncFunction("prepareForSubmit") { (view: T3ComposerEditorView) in
+ view.prepareForSubmit()
+ }
AsyncFunction("setSelection") { (view: T3ComposerEditorView, start: Int, end: Int) in
view.setSelection(start: start, end: end)
18 additions and 0 deletionsapps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swiftModified
View file
@@ -773,6 +773,24 @@
textView.resignFirstResponder()
​
+ func prepareForSubmit() -> [String: Any] {
+ // Ending editing accepts UIKit's pending autocorrection synchronously.
+ let wasEditing = textView.isFirstResponder
+ textView.resignFirstResponder()
+ value = textView.serializedText()
+ if wasEditing {
+ textView.becomeFirstResponder()
+ }
+ let selection = sourceSelection()
+ // Delayed editing events must not restore the submitted draft.
+ nativeEventCount += 1
+ return [