diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index 616a6014a..bd5ebddaf 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -567,6 +567,10 @@ const BottomSheetComponent = forwardRef( return animatedPosition.value; } + if (!isAnimatedOnMount.value) { + return snapPoints[_providedIndex]; + } + return snapPoints[currentIndex]; }, [ @@ -579,8 +583,10 @@ const BottomSheetComponent = forwardRef( animatedPosition, animatedSnapPoints, isInTemporaryPosition, + isAnimatedOnMount, keyboardBehavior, keyboardBlurBehavior, + _providedIndex, ] ); const handleOnChange = useCallback( @@ -1238,7 +1244,7 @@ const BottomSheetComponent = forwardRef( nextPosition = animatedClosedPosition.value; animatedNextPositionIndex.value = -1; } else { - nextPosition = animatedSnapPoints.value[_providedIndex]; + nextPosition = getNextPosition(); } runOnJS(print)({ @@ -1371,37 +1377,52 @@ const BottomSheetComponent = forwardRef( ) : Math.abs(_keyboardHeight - animatedContainerOffset.value.bottom); + /** + * if keyboard state is equal to the previous state, then exit the method + */ + if ( + _keyboardState === _previousKeyboardState && + _keyboardHeight === _previousKeyboardHeight + ) { + return; + } + + /** + * if user is interacting with sheet, then exit the method + */ const hasActiveGesture = animatedContentGestureState.value === State.ACTIVE || animatedContentGestureState.value === State.BEGAN || animatedHandleGestureState.value === State.ACTIVE || animatedHandleGestureState.value === State.BEGAN; + if (hasActiveGesture) { + return; + } + + /** + * if sheet not animated on mount yet, then exit the method + */ + if (!isAnimatedOnMount.value) { + return; + } + + /** + * if new keyboard state is hidden and blur behavior is none, then exit the method + */ + if ( + _keyboardState === KEYBOARD_STATE.HIDDEN && + keyboardBlurBehavior === KEYBOARD_BLUR_BEHAVIOR.none + ) { + return; + } + /** + * if platform is android and the input mode is resize, then exit the method + */ if ( - /** - * if keyboard state is equal to the previous state, then exit the method - */ - (_keyboardState === _previousKeyboardState && - _keyboardHeight === _previousKeyboardHeight) || - /** - * if user is interacting with sheet, then exit the method - */ - hasActiveGesture || - /** - * if sheet not animated on mount yet, then exit the method - */ - !isAnimatedOnMount.value || - /** - * if new keyboard state is hidden and blur behavior is none, then exit the method - */ - (_keyboardState === KEYBOARD_STATE.HIDDEN && - keyboardBlurBehavior === KEYBOARD_BLUR_BEHAVIOR.none) || - /** - * if platform is android and the input mode is resize, then exit the method - */ - (Platform.OS === 'android' && - keyboardBehavior === KEYBOARD_BEHAVIOR.interactive && - android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize) + Platform.OS === 'android' && + keyboardBehavior === KEYBOARD_BEHAVIOR.interactive && + android_keyboardInputMode === KEYBOARD_INPUT_MODE.adjustResize ) { animatedKeyboardHeightInContainer.value = 0; return;