From a03106cc57da33595c7e9829261acd1956631a2e Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 26 Feb 2026 13:07:33 +0200 Subject: [PATCH] fix bottom sheet keyboard expansion with preventExpansion on android When preventExpansion is true, the maxHeight cap prevented the sheet from expanding when the keyboard opened. Lift the cap temporarily when the keyboard appears (updateLayout restores it on dismiss). Also broadened the state check to handle SETTLING state during rapid keyboard open/close. Fixes #9943 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../java/expo/modules/bottomsheet/BottomSheetView.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt b/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt index 300c338f9f..e8e640ea2b 100644 --- a/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt +++ b/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt @@ -254,8 +254,16 @@ class BottomSheetView( val wasKeyboardVisible = isKeyboardVisible isKeyboardVisible = imeVisible - if (imeVisible && behavior?.state == BottomSheetBehavior.STATE_HALF_EXPANDED) { - behavior.state = BottomSheetBehavior.STATE_EXPANDED + if (imeVisible && behavior != null && bottomSheet != null && behavior.state != BottomSheetBehavior.STATE_EXPANDED && behavior.state != BottomSheetBehavior.STATE_HIDDEN) { + if (preventExpansion) { + behavior.maxHeight = (screenHeight - getStatusBarHeight()).toInt() + bottomSheet.requestLayout() + bottomSheet.post { + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + } else { + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } } else if (!imeVisible && wasKeyboardVisible) { updateLayout() }