@@ -542,7 +542,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
542542 ) ;
543543 // biome-ignore lint/correctness/useExhaustiveDependencies(BottomSheet.name): used for debug only
544544 const handleOnAnimate = useCallback (
545- function handleOnAnimate ( targetIndex : number , targetPosition : number ) {
545+ function handleOnAnimate ( targetIndex : number , targetPosition : number , source : ANIMATION_SOURCE ) {
546546 if ( __DEV__ ) {
547547 print ( {
548548 component : BottomSheet . name ,
@@ -561,12 +561,16 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
561561 return ;
562562 }
563563
564- if ( targetIndex !== animatedCurrentIndex . value ) {
564+ if ( targetIndex !== animatedCurrentIndex . value
565+ // there is a race condition when opening and immedately closing the bottom sheet, where
566+ // the animatedCurrentIndex is not updated yet. As we don't want to miss close events we always call the callback for -1 changes:
567+ || targetIndex === - 1 ) {
565568 _providedOnAnimate (
566569 animatedCurrentIndex . value ,
567570 targetIndex ,
568571 animatedPosition . value ,
569- targetPosition
572+ targetPosition ,
573+ source ,
570574 ) ;
571575 }
572576 } ,
@@ -675,7 +679,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
675679 /**
676680 * fire `onAnimate` callback
677681 */
678- runOnJS ( handleOnAnimate ) ( animatedNextPositionIndex . value , position ) ;
682+ runOnJS ( handleOnAnimate ) ( animatedNextPositionIndex . value , position , source ) ;
679683
680684 /**
681685 * start animation
0 commit comments