@@ -116,6 +116,7 @@ const Carousel = React.forwardRef<
116116 api . on ( "select" , onSelect )
117117
118118 return ( ) => {
119+ api ?. off ( "reInit" , onSelect )
119120 api ?. off ( "select" , onSelect )
120121 }
121122 } , [ api , onSelect ] )
@@ -197,7 +198,7 @@ CarouselItem.displayName = "CarouselItem"
197198const CarouselPrevious = React . forwardRef <
198199 HTMLButtonElement ,
199200 React . ComponentProps < typeof Button >
200- > ( ( { className, variant = "outline" , size = "icon" , ...props } , ref ) => {
201+ > ( ( { className, variant = "outline" , size = "icon" , onClick , ...props } , ref ) => {
201202 const { orientation, scrollPrev, canScrollPrev } = useCarousel ( )
202203
203204 return (
@@ -213,7 +214,7 @@ const CarouselPrevious = React.forwardRef<
213214 className
214215 ) }
215216 disabled = { ! canScrollPrev }
216- onClick = { scrollPrev }
217+ onClick = { ( e ) => { scrollPrev ( ) ; onClick ?. ( e ) ; } }
217218 { ...props }
218219 >
219220 < ArrowLeft className = "h-4 w-4" />
@@ -226,7 +227,7 @@ CarouselPrevious.displayName = "CarouselPrevious"
226227const CarouselNext = React . forwardRef <
227228 HTMLButtonElement ,
228229 React . ComponentProps < typeof Button >
229- > ( ( { className, variant = "outline" , size = "icon" , ...props } , ref ) => {
230+ > ( ( { className, variant = "outline" , size = "icon" , onClick , ...props } , ref ) => {
230231 const { orientation, scrollNext, canScrollNext } = useCarousel ( )
231232
232233 return (
@@ -242,7 +243,7 @@ const CarouselNext = React.forwardRef<
242243 className
243244 ) }
244245 disabled = { ! canScrollNext }
245- onClick = { scrollNext }
246+ onClick = { ( e ) => { scrollNext ( ) ; onClick ?. ( e ) ; } }
246247 { ...props }
247248 >
248249 < ArrowRight className = "h-4 w-4" />
0 commit comments