Skip to content

Commit

Permalink
fix(1887): updated the keyboard handling for Android with keyboard in…
Browse files Browse the repository at this point in the history
…put mode resize
  • Loading branch information
gorhom committed Jul 28, 2024
1 parent 919be39 commit 08db4ab
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,13 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
*/
if (
keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&
keyboardState === KEYBOARD_STATE.SHOWN
keyboardState === KEYBOARD_STATE.SHOWN &&
// ensure that this logic does not run on android
// with resize input mode
!(
Platform.OS === 'android' &&
android_keyboardInputMode === 'adjustResize'
)
) {
isInTemporaryPosition.value = true;
const keyboardHeightInContainer =
Expand Down Expand Up @@ -895,7 +901,10 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
* when evaluating the position while the bottom sheet is
* closing, then we force closing the bottom sheet with no animation.
*/
if (animatedNextPositionIndex.value === -1) {
if (
animatedNextPositionIndex.value === -1 &&
!isInTemporaryPosition.value
) {
setToPosition(animatedClosedPosition.value);
return;
}
Expand All @@ -907,7 +916,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
*/
if (animatedNextPositionIndex.value !== animatedCurrentIndex.value) {
animateToPosition(
animatedNextPosition.value,
animatedSnapPoints.value[animatedNextPositionIndex.value],
source,
undefined,
animationConfigs
Expand Down Expand Up @@ -1565,6 +1574,20 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
)
: Math.abs(_keyboardHeight - animatedContainerOffset.value.bottom);

/**
* if platform is android and the input mode is resize, then exit the method
*/
if (
Platform.OS === 'android' &&
android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize
) {
animatedKeyboardHeightInContainer.value = 0;

if (keyboardBehavior === KEYBOARD_BEHAVIOR.interactive) {
return;
}
}

/**
* if user is interacting with sheet, then exit the method
*/
Expand All @@ -1587,18 +1610,6 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
return;
}

/**
* if platform is android and the input mode is resize, then exit the method
*/
if (
Platform.OS === 'android' &&
keyboardBehavior === KEYBOARD_BEHAVIOR.interactive &&
android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize
) {
animatedKeyboardHeightInContainer.value = 0;
return;
}

let animationConfigs = getKeyboardAnimationConfigs(
keyboardAnimationEasing.value,
keyboardAnimationDuration.value
Expand Down

0 comments on commit 08db4ab

Please sign in to comment.