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:
+10
-2
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user