-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[android] Mounting multiple KeyboardAvoidingViews across different mounted screens cause conflicts with one another #267
Comments
Interesting, thank you for your report @erickreutz Mat I ask you which Android version did you test? |
@kirillzyusko Pixel 6 Pro API 31:5554 |
@erickreutz Do I correctly understand, that you are using next steps to reproduce?
If yes, then don't you mind to test #268 and see whether the issue has gone for you? 👀 |
@kirillzyusko yes, you understand correctly - just tried your branch out in my test app and it's working as expected now - thank you!! |
@erickreutz awesome! I'll fix CI tomorrow and will try to prepare a new release! 😎 |
@kirillzyusko Great thank you! also, I thought I should let you know that after further testing the problem still seems to persist if you set |
@erickreutz I can not reproduce it in my example app... Any ideas what I'm doing wrong? Screen.Recording.2023-11-12.at.21.33.16.mov |
@kirillzyusko Hmm yeah I think it may have been a bug in my own code - sorry about that. |
@erickreutz ah, okay 🙂 Then I'm going to close this issue - feel free to open new one if you discover any issues 👀 |
## 📜 Description Compare size of keyboard in `onApplyWindowInsets` callback. ## 💡 Motivation and Context When you have an opened keyboard and you trigger a navigation from screen A to screen B, then you'll have a race condition between `onApplyWindowInsets` and `onStart`/`onProgress`/`onEnd` callbacks. For this particular case `onApplyWindowInsets` shouldn't emit events, because in this method I'm simply detecting keyboard resize. With old condition if-statement: ```kt if (isKeyboardShown && !isMoving && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) ``` is evaluated as `true` and because of that we're dispatching unnecessary events. Since this method was designed to detect keyboard layout changes/resizing I thought that it would be good to add additional condition that compares previous and current height. With this fix the race condition will gone, because keyboard is not changes its size when you perform navigation. Another case that would be solved by this PR is when you open a keyboard, let your screen to dim (become fully dark/turned off, but not to be locked yet), and touch it to wake your phone - in this case `onApplyWindowInsets` is also dispatching and before we were sending unnecessary events. Now it'll not happen, because size of the keyboard is the same 🙃 Closes #267 ## 📢 Changelog ### Android - changed `DEFAULT_ANIMATION_TIME` to int; - added `isKeyboardSizeEqual` variable; - used `isKeyboardSizeEqual` variable as `!isKeyboardSizeEqual` in if-statement. ## 🤔 How Has This Been Tested? Tested manually on Pixel 3A (API 33). ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<video src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/3c36fe8a-1a73-4f8b-8220-de4757f6fa85">|<video src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/cd4f9c2b-c013-46e5-8e5d-a41e9b5f51f0">| ## 📝 Checklist - [x] CI successfully passed
Published under |
If I set
enabled={false}
on screen 1 then screen 2 works as expected.It should also be noted that this does not seem to be an issue on iOS.
Both Screen 1 and Screen 2 use the exact same code
The text was updated successfully, but these errors were encountered: