-
-
Notifications
You must be signed in to change notification settings - Fork 562
feat(v4): new implementation for the InputOTP component
#1505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
β¦the icon easily
componentField contains v-model binding
| data-slot="input-otp" | ||
| class="disabled:cursor-not-allowed" | ||
| > | ||
| {{ updateContext(slotProps) }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there! π
I believe itβs better to provide context from vue-input-otp instead of from within the <template>.
For now, let's use slotProps. π
I will try to update the upstream repository and submit a pull request, but it may take some time that is why we need to stick with slotProps for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly what I thought as well. Having this provided from the package would be a lot cleanerππ»
|
No need to revert back to slotProps Managed to work on it Will update this PR afterwards Thanks for your contribution π«‘β€οΈ |
|
What a mighty PR you made there! π Hope this will get merged soon, it'll bring this project a little closer to v4 being ready :) You're welcome ofc, thx for your awesome work! β€οΈ |
π Linked issue
-
β Type of change
π Description
This PR adds the new
InputOTPcomponent using wobsoriano/vue-input-otp that behaves as closely as possible to the one in the current version of shadcn/ui as we discussed in #1503 πSteps taken
InputOTPcomponent on the v4 registryOTPInputto accept all kinds of characters (.*) instead having the default invue-input-otponly accept digits and letters. I did this to match the behaviour of the original guilhermerodz/input-otp react library and therefore shadcn/ui. We could discuss here whether we should make a PR in wobsoriano/vue-input-otp to possibly change this default, or just to have this override in our component.React.contextusage in shadcn/ui throughotp-input. This behaviour is not provided fromvue-input-otp, as it only gives us slot props to use.Known issue
There is a minor bug when typing characters into an otp input where the
patterndoes not allow the typed characters.Example:
:pattern="REGEXP_ONLY_DIGITS_AND_CHARS"and typing "#$%" moves the focused slot forward (but also inconsistently), which is not the case in shadcn/ui. As this is controlled viavue-input-otp, I likely suspect the issue to be in there instead of on our side.Here's a video of me repeatedly typing
#into the pattern example on the docs page:Screen.Recording.2025-10-26.at.15.51.15.mov
As you see, the characters correctly don't show up in the input, but the focussed input segment moves forward, and sometimes also backwards.
πΈ Screenshots (if appropriate)
π Checklist