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) <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-02-26 13:07:33 +02:00
parent 8e2a5abfff
commit a03106cc57
@@ -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()
}