Skip to content

Commit 20de151

Browse files
committed
fix(#2449): adjust next index to current index when animating to a temporary position
1 parent 1b618c3 commit 20de151

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,20 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
644644
}
645645

646646
const { detents } = animatedDetentsState.get();
647-
const index = detents?.indexOf(position + offset) ?? -1;
647+
let index = detents?.indexOf(position + offset) ?? -1;
648+
649+
/**
650+
* because keyboard position is not part of the detents array,
651+
* we need to keep the index to the current index.
652+
*/
653+
if (
654+
index === -1 &&
655+
status === KEYBOARD_STATUS.SHOWN &&
656+
source === ANIMATION_SOURCE.KEYBOARD &&
657+
isInTemporaryPosition.get()
658+
) {
659+
index = animatedCurrentIndex.value;
660+
}
648661

649662
/**
650663
* set the animation state
@@ -687,6 +700,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
687700
animatedAnimationState,
688701
animatedKeyboardState,
689702
animatedPosition,
703+
animatedCurrentIndex,
704+
isInTemporaryPosition,
690705
]
691706
);
692707
/**

0 commit comments

Comments
 (0)