Skip to content

[OneTimePasswordField] Paste Exceeding Max Length Is Not Truncated #3550

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

Open
ohprettyhak opened this issue May 19, 2025 · 3 comments · May be fixed by #3551
Open

[OneTimePasswordField] Paste Exceeding Max Length Is Not Truncated #3550

ohprettyhak opened this issue May 19, 2025 · 3 comments · May be fixed by #3551

Comments

@ohprettyhak
Copy link

Bug report

Current Behavior

Regardless of how many <OneTimePasswordField.Input> elements are rendered, if you copy and paste text into the field, all of the pasted characters are inserted, even beyond the intended length.

Expected behavior

Any characters beyond the configured number of inputs should be truncated—excess text should not be added to the field.

Reproducible example

  1. Navigate to the Radix UI One Time Password Field demo:
    https://www.radix-ui.com/primitives/docs/components/one-time-password-field
  2. Copy a string of more than 6 digits.
  3. Click into the OTP field and paste.
  4. Observe that all digits appear, overflowing the intended 6-character limit.

Suggested solution

On value change (e.g. in the onValueChange handler), verify the new value’s length and slice it to the maximum allowed length before updating state.

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-one-time-password-field ^0.1.6
React n/a ^19.1.0
npm/yarn/pnpm pnpm 10.11.0
@ohprettyhak ohprettyhak changed the title [OneTimePasswordField] Pasting Input Exceeds Maximum Length [OneTimePasswordField] Paste Exceeding Max Length Is Not Truncated May 19, 2025
@nayounsang
Copy link
Contributor

Can I try this issue? I have worked on radix OTP several times

@ohprettyhak
Copy link
Author

Can I try this issue? I have worked on radix OTP several times

It would be great if you could fix this issue. 😀

@injae-kim
Copy link

Fix PR by @nayounsang : #3551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants