fix: prevent crash when no first responder #444
Merged
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
Prevent crash when no first responder in
keyboardWillShow.💡 Motivation and Context
It happens because we can not find first responder when
keyboardWillShowis triggerred:Then we get NPE here (read
absoluteYofnil):And finally app crashes:
To fix this problem I've decided to add
guardstatement - there is no sense to execute code further if we don't have a reference toTextInput- no sense to store it in holder, no sense to add listeners/observers, substitute delegates etc.📢 Changelog
iOS
🤔 How Has This Been Tested?
Tested manually on iPhone 15.
📸 Screenshots (if appropriate):
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-05-14.at.17.18.14.mp4
📝 Checklist