Skip to content

Commit 08db4ab

Browse files
committed
fix(1887): updated the keyboard handling for Android with keyboard input mode resize
1 parent 919be39 commit 08db4ab

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/components/bottomSheet/BottomSheet.tsx

+26-15
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,13 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
799799
*/
800800
if (
801801
keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&
802-
keyboardState === KEYBOARD_STATE.SHOWN
802+
keyboardState === KEYBOARD_STATE.SHOWN &&
803+
// ensure that this logic does not run on android
804+
// with resize input mode
805+
!(
806+
Platform.OS === 'android' &&
807+
android_keyboardInputMode === 'adjustResize'
808+
)
803809
) {
804810
isInTemporaryPosition.value = true;
805811
const keyboardHeightInContainer =
@@ -895,7 +901,10 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
895901
* when evaluating the position while the bottom sheet is
896902
* closing, then we force closing the bottom sheet with no animation.
897903
*/
898-
if (animatedNextPositionIndex.value === -1) {
904+
if (
905+
animatedNextPositionIndex.value === -1 &&
906+
!isInTemporaryPosition.value
907+
) {
899908
setToPosition(animatedClosedPosition.value);
900909
return;
901910
}
@@ -907,7 +916,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
907916
*/
908917
if (animatedNextPositionIndex.value !== animatedCurrentIndex.value) {
909918
animateToPosition(
910-
animatedNextPosition.value,
919+
animatedSnapPoints.value[animatedNextPositionIndex.value],
911920
source,
912921
undefined,
913922
animationConfigs
@@ -1565,6 +1574,20 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
15651574
)
15661575
: Math.abs(_keyboardHeight - animatedContainerOffset.value.bottom);
15671576

1577+
/**
1578+
* if platform is android and the input mode is resize, then exit the method
1579+
*/
1580+
if (
1581+
Platform.OS === 'android' &&
1582+
android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize
1583+
) {
1584+
animatedKeyboardHeightInContainer.value = 0;
1585+
1586+
if (keyboardBehavior === KEYBOARD_BEHAVIOR.interactive) {
1587+
return;
1588+
}
1589+
}
1590+
15681591
/**
15691592
* if user is interacting with sheet, then exit the method
15701593
*/
@@ -1587,18 +1610,6 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
15871610
return;
15881611
}
15891612

1590-
/**
1591-
* if platform is android and the input mode is resize, then exit the method
1592-
*/
1593-
if (
1594-
Platform.OS === 'android' &&
1595-
keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&
1596-
android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize
1597-
) {
1598-
animatedKeyboardHeightInContainer.value = 0;
1599-
return;
1600-
}
1601-
16021613
let animationConfigs = getKeyboardAnimationConfigs(
16031614
keyboardAnimationEasing.value,
16041615
keyboardAnimationDuration.value

0 commit comments

Comments
 (0)