Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 📜 Description Make `useFocusedInputHandler` compatible with iOS < 13. ## 💡 Motivation and Context The library was always compatible with really old iOS versions. However there was a one handler (`onSelectionChange`) which was a stub on iOS < 13. In this PR I'm adding support for old iOS versions for this handler via `KVO` approach + dispatching events on text changes. The new algorithm can be breaking into next steps: - on saving a new reference to delegate we remove old KVO; - on saving a new reference to delegate we add KVO for UITextField (iOS < 13 only); - we dispatch selection event from KVO/change text events (to be fully backward comaptible with iOS 13+, because single KVO don't emit events for text changes - only selection); - when text editing has been completed - we remove KVO. One thing I potentially don't really like a lot is that we remove KVO in `endEditing` event. Starting from #760 we will return delegate to its original variant on `endEditing` event, but it seems like we'll have kind of transitive dependencies (the fact that we receive this event in two places). However at the moment I can not imagine a situation when we will not substitute delegate back when we finish text editing, so theoretically this solution should be okay. Closes #763 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### iOS - `setTextFieldDelegate` accepts second `textField` param; - store `observedTextFieldForSelection` in composite delegate class; - added KVO helpers function (to assure we can remove it only one time); - remove KVO when new delegate is set; - add new KVO when new delegate is set; - send selection events from text change/kvo; ## 🤔 How Has This Been Tested? Tested on macOS 12 with XCode 14 and iPhone X iOS 12.4 simulator. ## 📸 Screenshots (if appropriate): https://github.com/user-attachments/assets/98d01bae-0d58-42e7-9658-ff382b692087 ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
- Loading branch information