kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.62k stars 67 forks source link

fix: prevent crash when no first responder #444

Closed kirillzyusko closed 4 months ago

kirillzyusko commented 4 months ago

📜 Description

Prevent crash when no first responder in keyboardWillShow.

💡 Motivation and Context

It happens because we can not find first responder when keyboardWillShow is triggerred:

image

Then we get NPE here (read absoluteY of nil):

image

And finally app crashes:

image

To fix this problem I've decided to add guard statement - there is no sense to execute code further if we don't have a reference to TextInput - 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):

https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/83ecde49-69de-483e-8403-92c4dd41c4c7

📝 Checklist

github-actions[bot] commented 4 months ago

📊 Package size report

Current size Target Size Difference
136075 bytes 136074 bytes 1 bytes 📈