From 0c25f7dc19a257355519fc5e1ea6bc80414aee68 Mon Sep 17 00:00:00 2001 From: Krzysztof Piaskowy Date: Tue, 16 Jun 2026 11:07:53 +0200 Subject: [PATCH] Fix race condition update --- .../reanimated/keyboard/KeyboardAnimationCallback.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboard/KeyboardAnimationCallback.kt b/packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboard/KeyboardAnimationCallback.kt index 14f6ef28fd2b..a47d33b72cbd 100644 --- a/packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboard/KeyboardAnimationCallback.kt +++ b/packages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboard/KeyboardAnimationCallback.kt @@ -12,6 +12,8 @@ class KeyboardAnimationCallback( private val CONTENT_TYPE_MASK = WindowInsetsCompat.Type.ime() } + private var mPendingStartDispatch = false + override fun onStart( animation: WindowInsetsAnimationCompat, bounds: WindowInsetsAnimationCompat.BoundsCompat, @@ -20,7 +22,7 @@ class KeyboardAnimationCallback( return bounds } mKeyboard.onAnimationStart() - mNotifyAboutKeyboardChange.call() + mPendingStartDispatch = true return super.onStart(animation, bounds) } @@ -36,6 +38,7 @@ class KeyboardAnimationCallback( } } if (isAnyKeyboardAnimationRunning) { + mPendingStartDispatch = false mKeyboard.updateHeight(insets, mIsNavigationBarTranslucent) mNotifyAboutKeyboardChange.call() } @@ -44,6 +47,10 @@ class KeyboardAnimationCallback( override fun onEnd(animation: WindowInsetsAnimationCompat) { if (isKeyboardAnimation(animation)) { + if (mPendingStartDispatch) { + mNotifyAboutKeyboardChange.call() + } + mPendingStartDispatch = false mKeyboard.onAnimationEnd() mNotifyAboutKeyboardChange.call() }