Skip to content

Commit

Permalink
Move event.preventDefault() into the case statements. This allows chi…
Browse files Browse the repository at this point in the history
…ldren components to handle onKeyDown events.
  • Loading branch information
FlorianMgs committed May 15, 2024
1 parent 70ed258 commit 7e6d69d
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 @@ -105,10 +105,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 @@ -118,6 +118,7 @@ const Carousel = forwardRef<
}
break;
case "ArrowRight":
event.preventDefault();
if (orientation === "horizontal") {
if (direction === "rtl") {
ScrollPrev();
Expand All @@ -127,11 +128,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 7e6d69d

Please sign in to comment.