-
Notifications
You must be signed in to change notification settings - Fork 602
refactor(react): OTP Input Readability Enhancements #1692
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
🦋 Changeset detectedLatest commit: 51cd30d The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
ref={(e) => (boxEls.current[i] = e)} | ||
key={i} | ||
value={otp[i] === undefined ? "" : otp[i]} | ||
value={otp[i] ?? ""} |
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.
Prefer using nullish coalescing operator (??
) instead of a ternary expression, as it is simpler to read.
.slice(0, props.digits) | ||
.split("") | ||
.filter((n) => /[0-9]/.test(n)) | ||
.filter((n) => /\d/.test(n)) |
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.
Use concise character class syntax '\d' instead of '[0-9]'.
} | ||
|
||
if (!/[0-9]/.test(value) && value !== "") { | ||
if (!/\d/.test(value) && value !== "") { |
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.
Use concise character class syntax '\d' instead of '[0-9]'.
Thanks @etnlbck! |
@MananTank its strange that it's failing a unit test that has nothing to do with the change I made. I'll check on my side to see if there's anything I can do to resolve. Unless you have a better idea. |
Hey @etnlbck - Yes, we are aware that the failing tests are unrelated to changes made in this PR, We will merge this PR soon. Thanks! |
Signed-off-by: Juan Leal <114959779+juandolealt@users.noreply.github.com>
Problem solved
Made readability enhancements to simplify reading.
Changes made
Line 39 Prefer using nullish coalescing operator (
??
) instead of a ternary expression, as it is simpler to read.Line 47, 100 Use concise character class syntax '\d' instead of '[0-9]'.