Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check keyboard presence for
OverKeyboardView
(#636)
## 📜 Description Attach `OverKeyboardView` to `keyboardWindow` only if keyboard is visible. ## 💡 Motivation and Context The problem was because of the fact, that when we open a `WebBrowser` then `UIRemoteKeyboardWindow` from browser gets registered. And the problem is that when we close browser the window is not getting deregistered and we are attaching a view to invisible `keyboardWindow`. And view is not visible. To fix this problem initially I decided to check if the `keyboardView` instance is retrievable. And first testing showed that it fixes a problem. I. e. we: - open browser; - close browser; - show `OverKeyboardView` (it works); But if we add more scenarios, like opening a keyboard, closing keyboard, opening a browser, opening/closing keyboard, showing `OverKeyboardView` the check can be broken, because we have invalid `UIRemoteKeyboardWindow` and we already have a reference to keyboard instance, so we'll attach view to invalid window. To overcome this problem we need to check for actual keyboard visibility and attach a view to `keyboardWindow` only if: - `keyboardWindow` is available; - `keyboardView` is visible. To check if view is visible I added new extension `isVisibleInHierarchy` to `UIView`. I added both implementations, to optional and non-optional extension. Closes #635 ## 📢 Changelog ### iOS - add `isVisibleInHierarchy` to `UIView` extension; - check that `KeyboardView.find().isVisibleInHierarchy() == true` before returning `keyboardWindow`. ## 🤔 How Has This Been Tested? Tested in reproduction project on iPhone 15 Pro (iOS 17.5). ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<video src="https://github.com/user-attachments/assets/a78baaa4-e1bd-43d4-ad76-853193461b76">|<video src="https://github.com/user-attachments/assets/b8ea5dd5-019b-4d5e-b247-b7aeac93ba01">| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
- Loading branch information