Skip to content

Commit

Permalink
Merge pull request #53 from FlorianMgs/fix/carousel-handlekeydown-pre…
Browse files Browse the repository at this point in the history
…ventdefault

FIX: Carousel SliderMainItem children components not handling onKeyDown events
  • Loading branch information
BelkacemYerfa authored May 16, 2024
2 parents 02a894e + 7e6d69d commit e8f6bae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/registry/default/extension/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ const Carousel = forwardRef<

const handleKeyDown = useCallback(
(event: React.KeyboardEvent<HTMLDivElement>) => {
event.preventDefault();
if (!emblaMainApi) return;
switch (event.key) {
case "ArrowLeft":
event.preventDefault();
if (orientation === "horizontal") {
if (direction === "rtl") {
ScrollNext();
Expand All @@ -119,6 +119,7 @@ const Carousel = forwardRef<
}
break;
case "ArrowRight":
event.preventDefault();
if (orientation === "horizontal") {
if (direction === "rtl") {
ScrollPrev();
Expand All @@ -128,11 +129,13 @@ const Carousel = forwardRef<
}
break;
case "ArrowUp":
event.preventDefault();
if (orientation === "vertical") {
ScrollPrev();
}
break;
case "ArrowDown":
event.preventDefault();
if (orientation === "vertical") {
ScrollNext();
}
Expand Down

0 comments on commit e8f6bae

Please sign in to comment.