-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat(input-otp): add new input-otp component #30386
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
base: feature-8.6
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you, @brandyscarney, for your work on this component. One feature suggestion: pressing CTRL+A (or CMD+A on macOS) inside the component could select and clear all input fields at once. This would align with common input behavior and improve UX for users needing to re-enter their code quickly. Example: https://input-otp.rodz.dev/ |
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.
Some minor nits
ios: 'input-otp.ios.scss', | ||
md: 'input-otp.md.scss', | ||
}, | ||
scoped: true, |
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.
What is the reason for making this a scoped component vs a shadow one?
const pastedText = event.clipboardData?.getData('text') || ''; | ||
const validChars = pastedText | ||
.split('') | ||
.filter((char) => validKeys.test(char.toLowerCase())) |
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.
Why using toLowerCase
here? It seems like validKeys
considers lower and upper casing via /^[a-zA-Z0-9]$/i;
, when using a custom pattern, this may be confusing, no?
const { inputRefs, length, validKeys } = this; | ||
|
||
event.preventDefault(); | ||
const pastedText = event.clipboardData?.getData('text') || ''; |
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.
How about returning early here if nothing is in the clipboard?
const pastedText = event.clipboardData?.getData('text') || ''; | |
const pastedText = event.clipboardData?.getData('text'); | |
if (typeof pastedText === 'undefined') { | |
return | |
} |
Issue number: internal
What is the current behavior?
In order to re-create an OTP Input component users have to custom style an
<ion-input>
, possibly multiple, to get the design and functionality they want.What is the new behavior?
ion-input-otp
which provides the OTP input functionalityfill
,shape
,size
,color
separators
property to show a separator between 1 or more input boxesdisabled
,readonly
andinvalid
statespattern
propertyDoes this introduce a breaking change?
Other information
Previews