You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 📜 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
0 commit comments