-
Notifications
You must be signed in to change notification settings - Fork 624
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
feat(PinInput): implement component #2570
Conversation
I hope this implementation is okay even tough the radix-vue component is tagged as alpha in their docs. It will not work in a Form (validation etc.) i struggled to get that working. Hope the tests are good/fine as well as i have no expierence with that so far π |
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.
Wow π€© Thank you for doing this, you just saved me a lot of time and the PR looks perfect!
Did you find the CLI to start the component?
--- | ||
:: | ||
|
||
### Mask |
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.
Could it be worth having an example with otp
prop? Not sure what it does exactly though.
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.
I was thinking about that too but there is nothing to showcase. It does set the autocomplete type to "one-time-code". This is defined here: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#one-time-code
which then allows mobile users to autocomplete with the clipboard or from recieved messages.
https://github.com/unovue/radix-vue/blob/main/packages/radix-vue/src/PinInput/PinInputInput.vue#L159
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.
Shouldn't this be set by default then? π€ Nevermind, I added it to the docs!
You also have to run |
@romhml Could you have a look into this to handle it inside a form? |
@benjamincanac Thanks for the quick feedback! I adjusted the docs as you said. Yeah i found the cli, but actually after i already created the files and then i renamed everything againπ |
commit: |
I've made some changes to integrate the PinInput with the Form/FormField components. One thing I could not figure out is how to emit a |
@romhml i added the blur event. The event.relatedTarget will be null if the user leaves the input. It would be set to the next input element if the user enters a value. But i am still thinking about the change event. If you now test on the playground and you enter all 5 values it will validate and mark the field as invalid (because max. 4 allowed) but if you then remove the last entry it will not validate again as the change will only get called once all fields are filled. |
I made the playground example to test that the validation is triggered, I'll update it to have something more realistic. |
I added the form validation on blur and updated the example. The playground example does not work properly currently because the input uses an array rule, I'll do another PR to fix this. |
I added the |
Thanks @maxsteinwand! π |
π Linked issue
Resolves #1123
β Type of change
π Description
Add the PinInput component from radix-vue. https://www.radix-vue.com/components/pin-input
Tests and Documentation are also added.
π Checklist