Skip to content

Conversation

controversial
Copy link
Contributor

@controversial controversial commented Aug 13, 2025

Autocomplete in OneTimePasswordFields is broken on iOS Chrome, see #3641.

This is because:

  • OneTimePasswordFieldInput expects a password manager / autocomplete provider to enter the full code in the first input. When it encounters this case in the input event handler, it dispatches the PASTE action.
  • However, iOS chrome autocomplete appears to limit the length of its input event’s value for the maxLength property set on the target input

The solution is to increase the maxLength on the input that expects to receive autocomplete input (the input that has supportsAutoComplete) so that it can receive up to collection.size characters of input, rather than just one.

Closes #3641.

Adds additional handling for a bug caused by iOS Chrome firing onChange on the first input after it fires the input event—this had caused OneTimePasswordField to focus the second input where it should be focusing the final input (of the “pasted” value).

(I’m not sure how to add tests for this PR as it’s specific to the iOS chrome environment, but I can try)

iOS chrome autocomplete only fires an `input` event up to the `maxLength`, so we need the input that “supports autocomplete” to accept the full OTP length. 

Later, in the `input` handler, the PASTE action will be dispatched.
Copy link

changeset-bot bot commented Aug 13, 2025

🦋 Changeset detected

Latest commit: f7ad0d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@radix-ui/react-one-time-password-field Patch
radix-ui Patch

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

@controversial controversial changed the title Fix iOS Chrome autocomplete for OneTimePasswordField [OneTimePasswordField] Fix iOS Chrome autocomplete Aug 13, 2025
- iOS Chrome fires onChange for the first input after firing `onInput` with the full code
- If unchecked, the onChange handler will result in the _second_ input being pressed, after the PASTE action handler already focused the _final_ input
@controversial
Copy link
Contributor Author

Compared to #3643, this PR:

  • Fixes autocomplete automatically, without requiring that the user knows how/where to override maxLength to get correct behavior.
  • Handles a secondary bug where a rogue onChange event resulted in the second input being focused after autocomplete (instead of the final input)

@controversial
Copy link
Contributor Author

controversial commented Aug 13, 2025

cc @chaance, if you have the capacity to review and slide this into the next release, that would be really helpful ❤️

nvm #3656

@chaance
Copy link
Member

chaance commented Aug 14, 2025

@controversial Had an accidental lint error slip through on main. Mind updating your branch so tests can re-run in CI?

@controversial
Copy link
Contributor Author

controversial commented Aug 14, 2025

@chaance I just rebased off the latest main; lints and tests are now passing, at least on my local

@chaance chaance merged commit 36d954d into radix-ui:main Aug 14, 2025
2 checks passed
@controversial
Copy link
Contributor Author

@chaance It looks like this was released under 1.4.3-rc.1755205432459 even though the stable release is already 1.4.3; do the experimental releases need to be bumped to 1.4.4?

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

Successfully merging this pull request may close these issues.

[OneTimePasswordField] autoComplete not working in Chrome on iOS
2 participants