Skip to content

Commit

Permalink
fix: try to ignore noFocusedInputEvent and don't dispatch it immedi…
Browse files Browse the repository at this point in the history
…ately
  • Loading branch information
kirillzyusko committed Jan 16, 2025
1 parent b33481d commit 5e8d81a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ios/observers/FocusedInputObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class FocusedInputObserver: NSObject {
}

@objc func keyboardWillShow(_: Notification) {
print("keyboardWillShow")
print("keyboardWillShow \(Date.currentTimeStamp)")
guard let responder = UIResponder.current as? UIView else { return }
removeObservers(newResponder: responder)
currentResponder = responder
Expand All @@ -128,13 +128,17 @@ public class FocusedInputObserver: NSObject {
}

@objc func keyboardWillHide(_: Notification) {
print("keyboardWillHide \(UIResponder.current)")
print("keyboardWillHide \(UIResponder.current) \(Date.currentTimeStamp)")
removeObservers(newResponder: nil)
currentInput = nil
currentResponder = nil
// when root view is in responder chain
if UIResponder.current != nil {
dispatchEventToJS(data: noFocusedInputEvent)

DispatchQueue.main.async {
if self.currentResponder == nil {
// Still no new focus — user truly left input
self.dispatchEventToJS(data: noFocusedInputEvent)
print("keyboardWillHide \(UIResponder.current) \(Date.currentTimeStamp)")
}
}
}

Expand Down

0 comments on commit 5e8d81a

Please sign in to comment.