Skip to content

fix(ui): submit one verification code at a time - #11048

Merged
alexcarpenter merged 3 commits into
mainfrom
carp/2fa-input-bug
Dec 2, 2026
Merged

alexcarpenter merged 3 commits into
mainfrom
carp/2fa-input-bug

Conversation

@alexcarpenter

@alexcarpenter alexcarpenter commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Description

With an external keyboard connected to an iPhone, SMS code autofill can change the OTP input's value several times. useFieldOTP submitted every 6-digit value it saw, so several wrong codes went out at once and users got locked out with "Too many failed attempts".

A code completed while another is being verified is now queued instead of submitted. It is submitted only if the in-flight one fails and the queued code is different.

What we know about the iOS side, from a device trace captured with the probe page linked in the comments:

  • iOS delivers the autofilled code as fake key presses. For the code 795598 it sent 7 ⌫ 7 9 9 5 5 5 5 9 9 8 8 ⏎: each digit twice, plus a stray backspace.

  • Once the field is full, input-otp selects the last box, so each extra key press overwrites the last digit. The value went 799555 → 799559 → 799558, which made 3 submits before this change.

  • A plain <input maxlength=6 autocomplete=one-time-code> gets the same pattern (6 ⌫ 6 55 11 66 66 22) and ends with a wrong code too, so this is an iOS bug, not input-otp. Reported to Apple as FB25796827.

This change limits the damage but does not make autofill work in this case. None of those values is the real code, so the user still sees at most 2 failed attempts and has to type the code by hand.

Raises the ui-common bundlewatch limit from 142KB to 144KB: the change put it at 142.02KB, and bundlewatch:fix rounds up.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Dec 1, 2026 9:07pm UTC
swingset Ready Ready Preview Dec 1, 2026 9:07pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
mosaic-docs Skipped Skipped Dec 1, 2026 9:07pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cb1f580

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

This PR includes changesets to release 2 packages
Name Type
@clerk/ui Patch
@clerk/chrome-extension 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

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

useFieldOTP now queues the latest code entered while another code is being verified. If verification fails and the queued code differs from the failed code, the hook submits it. Otherwise, the hook retains the existing delay and reset behavior. New tests cover pending verification and rejection. A changeset documents the OTP fix. The ui-common bundle size limit increases from 142KB to 144KB.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: austincalvelage

Merge Risk: Minimal · up to cb1f5

This change makes the OTP input submit one verification code at a time and retry a queued code only after a failure. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(ui): submit one verification code at a time" states the main change. The changeset queues a code entered during an in-flight OTP verification and submits it only if the in-flight attemp…
Description check Passed The description explains the bug. With iOS SMS autofill and an external keyboard, useFieldOTP submitted several 6-digit values and caused lockouts. It describes the fix, which queues a code entered du…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(ui): submit one verification code at a time" states the main change. The changeset queues a code entered during an in-flight OTP verification and submits it only if the in-flight attempt fails. The title is specific and uses the conventional fix(ui) scope. It is concise and has no file lists or vague terms.

Full details: Description check

Explanation

The description explains the bug. With iOS SMS autofill and an external keyboard, useFieldOTP submitted several 6-digit values and caused lockouts. It describes the fix, which queues a code entered during verification and submits it only if the in-flight attempt fails and the queued code differs. It also gives the iOS trace, the remaining limitation, and the bundlewatch limit change, all of which match the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 68d9cf7 and cb1f580.

Files selected for processing: 1

  • packages/ui/src/elements/__tests__/CodeControl.test.tsx
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Finishing Touches
Fix failing CI checks

  • Commit to this branch
  • Create a new PR

@blacksmith-sh

blacksmith-sh Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Matches iOS-style autofill sends one 2FA code at a time

Head sent 799555 alone and 799558 only after its 422 (max 1 in flight). Base sent both at +0ms, 2 in flight.

Narrowed from "When the SMS code field's value changes several times in a burst (799555, 799559, 799558, like iOS autofill with an external keyboard), the sign-in submits only the first code, then the latest queued..."

Before · Recording

Recording

Watch full video · Original footage · 0:00 iOS-style autofill · 0:00 Result

After · Recording

Recording

Watch full video · Original footage · 0:00 iOS-style autofill · 0:00 Result

Merge-base

Request log

This PR cb1f5803

Request log

Also checked · 1 match

Matches Typing the right code after failed autofill still signs in

Proof on cb1f5803 · mocked: Clerk Frontend API (MSW mock scenario sandbox/scenarios/proof-phone-code-2fa.ts stubs a phone_code 2...) · Did Proof get it right? Yes · No

View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-12-01T21:09:21.187Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on cb1f580.

@pkg-pr-new

pkg-pr-new Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@11048

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@11048

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@11048

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@11048

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@11048

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@11048

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@11048

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@11048

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@11048

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@11048

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@11048

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@11048

@clerk/express

npm i https://pkg.pr.new/@clerk/express@11048

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@11048

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@11048

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@11048

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@11048

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@11048

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@11048

@clerk/react

npm i https://pkg.pr.new/@clerk/react@11048

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@11048

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@11048

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@11048

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@11048

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@11048

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@11048

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@11048

commit: cb1f580

@alexcarpenter
alexcarpenter merged commit 63e0f97 into main Dec 2, 2026
140 of 141 checks passed
@alexcarpenter
alexcarpenter deleted the carp/2fa-input-bug branch December 2, 2026 15:38

This branch was successfully deployed

2 active deployments
Preview – swingset — cb1f5803 Deployed Dec 1, 2026 by vercel[bot]
Preview – clerk-js-sandbox — cb1f5803 Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants