fix: missing unfocus
event on iOS Fabric
#799
Merged
+1
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Fixed a problem when input looses a focus, but
FocusedInputObserver
doesn't sendnoFocusedInputEvent
to JS.💡 Motivation and Context
The problem was introduced in this PR #760 before we were relying on keyboard evens, but in #760 I re-worked the approach and started to use blur/focus events. However I couldn't use only input events, because on iOS 15 keyboard event (
keyboardWillShow
) was arriving earlier than focus event, and for us it's crucial to know the layout of focused input insideonStart
(i. e. before keyboard movement starts).I decided to keep backward compatibility and keep keyboard events in place. However it comes with own set of challenges. For example:
This check works well for Paper, but doesn't work for Fabric. And for focus events we can keep two event sources, because logic for focus is simple -> "we got a focus -> save the state and push event to JS". For blur it's different:
blur
event but we should ignore it;Initially I don't know how to fix it. But then I realized, that on Android we already have a similar situation. We can looses a focus and keyboard will be focus, we can have a focus and close a keyboard, so overall it's a very similar to what we can have on iOS right now. But why I don't experience any problems on Android? Because I just rely on "focus"/"blur" events there (and actually relying on
keyboardWillShow
on iOS is needed to have a stable order of events in JS). So at this point of time I thought "what if I removekeyboardWillHide
handler?". Yes, it will not work as before (some events may be delayed), but for dismissing keyboard it's not so important at the moment (because on Android we can also have any order of those events).So after thinking a lot I decided that it can be safe to remove that handler completely and reduce logic complexity presented in this class.
Closes #798
📢 Changelog
iOS
blur
event only for sendingnoFocusedInputEvent
(removekeyboardWillHide
event);blur
eventUIResponder.current
presence instead ofself.currentResponder
.🤔 How Has This Been Tested?
Tested manually on iPhone 15 Pro iOS 17.5
📸 Screenshots (if appropriate):
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2025-02-07.at.10.41.32.mp4
📝 Checklist