fix: switch between inputs with KeyboardGestureArea on iOS#938
Merged
kirillzyusko merged 5 commits intoJun 3, 2025
Conversation
Contributor
📊 Package size report
|
b72342f to
17513a8
Compare
54f78bc to
5e7c320
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 with autoclosing keyboard if you switch between inputs +
KeyboardGestureAreahas activeoffset.💡 Motivation and Context
The key problem here is that in previous implementation
resignFirstRespondercall gets delayed, so first of all we callbecomeFirstResponder, then we callresignFirstResponder, but it's getting delayed, so new input get focus and then we callresignFirstResponderand keyboard gets closed.First fix that I did was saving pending request in
resignFirstResponder- I found out that it's getting called two times, and I thought if we call it second time and we have pending request -> we can immediately remove focus and cancel previous task. It works on simulator, but not on a real device - on a real device keyboard becomes hidden and then becomes visible.To fix all problems I decided to intercept
becomeFirstResponderevent, and save new focused input. IfresignFirstResponderis getting called and we have a pending request, then we should removeinputAccessoryViewimmediately + don't add any delays. In its turnbecomeFirstRespondershould store new focus request only for short amount of time - otherwise, if we store it permanently we can not distinguish a case "focus switch" vs "dismiss a keyboard", so current algorithm looks like:resignFistResponderand in the past frame we hadbecomeFirstResponderrequest -> we switch focus, so do a cleanup immediately;resignFistResponderand in the past frame we didn't havebecomeFirstResponderrequest -> removeinputAccessoryViewand close the keyboard (similar to how it was working before).📢 Changelog
iOS
becomeFirstResponder;resignFirstResponderpresence of current first responder and if we have it -> do a cleanup immediately.🤔 How Has This Been Tested?
Tested manually on iPhone 11 (iOS 17.4), with following code added before
ScrollView:📸 Screenshots (if appropriate):
ScreenRecording_06-03-2025.11-58-17.AM_1.MP4
📝 Checklist