From 40565139c44de62f850370b80c071a9ba36d6ace Mon Sep 17 00:00:00 2001 From: Kirill Zyusko Date: Thu, 17 Oct 2024 11:41:15 +0200 Subject: [PATCH] fix: do not substitute delegate back if it's `nil` (#642) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📜 Description Fixes a problem when all events such as `onFocus`/`onBlur`/etc. will stop working after keyboard dismissal. ## 💡 Motivation and Context It looks like a delegate in original `TextInput` can be somehow substituted and we are loosing a pointer to original delegate. If on keyboard-hide event we'll substitute delegate with `nil` - we will make all events, such as `onFocus`, `onBlur` etc. not coming to JS. So the most obvious decision is to check, if we actually have a delegate and do a substitution only in this case. Of course a rhetorical question arises - if we had original delegate, then injected our delegate, then it was substituted with a new one -> turns out that our events will not come, right? Right. But: - I don't know how it's possible - I checked RN sources and I don't see a way how delegate can be injected after component creation; - for now it's still safer to miss events in `keyboard-controller` rather than disable all events at framework level; - I can not reliably reproduce this in empty project and the issue is reproducible on relatively old devices (iO 15.2). So yeah, the problem is somewhere deeper, but I don't have an access to the code so can't debug what exactly happens there. So for now it'll be safer not to ruin the RN framework and merge this fix 🙃 Closes https://github.com/kirillzyusko/react-native-keyboard-controller/issues/456 ## 📢 Changelog ### iOS - check previous delegate presence when substitute delegate back; ## 🤔 How Has This Been Tested? Tested manually on iOS 15.2 ## 📸 Screenshots (if appropriate): |Before|After| |---|---| |