Skip to content

fix: allow iOS one-time-code AutoFill in OTP input - #293

Merged
brianorwhatever merged 2 commits into
mainfrom
fix/otp-ios-autofill
Oct 14, 2026
Merged

brianorwhatever merged 2 commits into
mainfrom
fix/otp-ios-autofill

Conversation

@brianorwhatever

Copy link
Copy Markdown
Contributor

Summary

  • Add autoComplete="one-time-code" to the OTP digit inputs so iOS offers the emailed code from Mail above the keyboard.
  • Remove maxLength={1} and handle a full code inserted into a single field (AutoFill inserts via input, not paste) by distributing digits across all boxes.
  • Typing into a filled box now replaces the digit.

Test plan

  • tsc and eslint pass
  • On iOS 17+, request a code, tap the first box, pick "From Mail" — code fills and auto-submits

🤖 Generated with Claude Code

Mark the digit fields with autocomplete="one-time-code" so iOS offers the
code from Mail, and accept a full code inserted into a single field
instead of rejecting it via maxLength=1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@railway-app

railway-app Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the boop-pr-293 environment in Friends

Service Status Web Updated
boop ✅ Success (View Logs) Web Oct 14, 2026 at 5:33 am UTC

@railway-app
railway-app Bot temporarily deployed to Friends / boop-pr-293 October 14, 2026 05:20 Destroyed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues. One rough edge, noted inline.

Reviewed changes

I reviewed the change that lets the 6-box OtpInput accept iOS/Android one-time-code AutoFill.

  • AutoFill hint: every digit input now has autoComplete="one-time-code", and maxLength={1} is gone, so the OS can insert the whole code.
  • Full-code distribution: handleChange strips non-digits. When 6 or more digits arrive in one field, it takes the last 6, fills all boxes and focuses the last one. The existing digits effect then auto-submits.
  • Overwrite on type: typing into a filled box keeps value.slice(-1) as the new digit, so the user doesn't have to delete the old one first.

The digit-by-digit typing path that tests/smoke-upgrade-journey.e2e.ts uses still works the same way.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread src/components/auth/OtpInput.tsx
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@railway-app
railway-app Bot temporarily deployed to Friends / boop-pr-293 October 14, 2026 05:31 Destroyed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ The earlier caret issue is fixed. One small iOS-specific suggestion inline.

Reviewed changes

I reviewed the one commit pushed since the last review.

  • Select digit on focus: Each OTP box now selects its contents on focus. That way, typing or AutoFill replaces the existing digit no matter where the caret was. This resolves the slice(-1) / slice(-OTP_LENGTH) caret-before-digit thread from the previous review.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

onChange={(e) => handleChange(index, e)}
onKeyDown={(e) => handleKeyDown(index, e)}
// Select existing digit so typing or AutoFill replaces it regardless of caret position
onFocus={(e) => e.target.select()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are reports that select() doesn't take effect in iOS Safari, and iOS is the platform this PR targets (example). If it doesn't work, a tap on a filled box falls back to the old caret behavior. The usual workaround is setSelectionRange. Worth confirming during the on-device test in the test plan.

Suggested change
onFocus={(e) => e.target.select()}
onFocus={(e) => e.target.setSelectionRange(0, e.target.value.length)}

@brianorwhatever
brianorwhatever merged commit e44a54e into main Oct 14, 2026
10 checks passed
@brianorwhatever
brianorwhatever deleted the fix/otp-ios-autofill branch October 14, 2026 05:35

This branch was successfully deployed

No deployments
Friends / boop-pr-293 — e04aa8ca Deployed Oct 14, 2026 by railway-app[bot]
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.

1 participant