-
SummaryI understand navigation between the slides is accessibility feature, but in my case, I'm using embla for my creating account flow, each step is a slide. I need to prevent the slide change when the user hits tab on the flow inputs. How can I achieve that? If applicable, which variants of Embla Carousel are relevant to this question?
Additional informationNo response CodeSandbox exampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 15 replies
-
Hi @gnllucena, This feature isn’t available yet but will be in a future release. Best, |
Beta Was this translation helpful? Give feedback.
-
While the feature is not implemented yet, that's how I'm hacking the feature into the current version: (I really don't recommend this solution, it makes the usability really terrible, but in my case, I must not let the user navigate to the next slides, unless they complete the current step) const handleKeyDown = React.useCallback(
(event: React.KeyboardEvent<HTMLDivElement>) => {
if (event.key === "Tab" && enableTabNavigation === false) {
event.preventDefault()
}
},
[enableTabNavigation, scrollPrev, scrollNext]
) <CarouselContext.Provider>
<div
onKeyDownCapture={handleKeyDown}
{...props}
>
{children}
</div>
</CarouselContext.Provider> The lib is amazing, I'm really waiting for this feature to be build into it. Thanks for the amazing work, @davidjerleke |
Beta Was this translation helpful? Give feedback.
-
Hi @gnllucena, were you able to navigate inside of an input with left and right arrow keys? Any way to hack that? |
Beta Was this translation helpful? Give feedback.
-
hey @harshpandey002, yes I was, I had to change a few lines of code from shadcn, and also had to hack a lot to make it work, unfortunately there's a few weird behaviors that I'm not sure if it's Embla or NextJs cache fault (honestly believe it's NextJs...) here's my Carousel.tsx:
and that's how I use it:
|
Beta Was this translation helpful? Give feedback.
hey @harshpandey002, yes I was, I had to change a few lines of code from shadcn, and also had to hack a lot to make it work, unfortunately there's a few weird behaviors that I'm not sure if it's Embla or NextJs cache fault (honestly believe it's NextJs...)
here's my Carousel.tsx: