We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3e059e7 commit ab8a334Copy full SHA for ab8a334
1 file changed
ios/observers/FocusedInputObserver.swift
@@ -142,7 +142,18 @@ public class FocusedInputObserver: NSObject {
142
setupObservers()
143
// dispatch onSelectionChange on focus
144
if let textInput = responder as? UITextInput {
145
- updateSelectionPosition(textInput: textInput, sendEvent: onSelectionChange)
+ if #available(iOS 16.0, *),
146
+ let textView = textInput as? UITextView,
147
+ textView.textLayoutManager != nil
148
+ {
149
+ // Using TextKit 2: layout may not be ready, so defer
150
+ DispatchQueue.main.async {
151
+ updateSelectionPosition(textInput: textInput, sendEvent: self.onSelectionChange)
152
+ }
153
+ } else {
154
+ // TextKit 1 (or pre-iOS 16): coords are ready synchronously
155
+ updateSelectionPosition(textInput: textInput, sendEvent: onSelectionChange)
156
157
}
158
159
syncUpLayout()
0 commit comments