Repository navigation
[otp field] Keep focus on the invalid field when autoSubmit is blocked - #5089
Merged
Merged
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,189.90 ms -38.27 ms(-3.1%) | Renders: 78 (+0)
11 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: yyh <[email protected]>
Contributor
Author
|
Failed e2e test case: https://app.circleci.com/pipelines/github/mui/base-ui/27331/workflows/7d3de905-9676-4980-b90c-a6d5e39d27dd/jobs/319195 This appears unrelated to my changes. |
lyzno1
marked this pull request as ready for review
June 20, 2026 11:32
lyzno1
requested review from
atomiks,
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
June 20, 2026 11:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5088.
This is a small attempt to fix the OTP Field auto-submit focus behavior. When an OTP value becomes complete, the field currently handles completion before its pending slot focus. If
autoSubmitcallsrequestSubmit()and Base UI Form blocks submission because an earlier field is invalid, the form focuses that invalid control, but the OTP pending focus then moves focus back to the final OTP slot.This PR processes the OTP pending focus before the completion callback. That keeps the normal accepted-value focus behavior, while allowing Form's invalid-field focus to be the final focus update when auto-submit is blocked.
If this order is not the intended behavior, I am happy to adjust or leave the maintainers to take a different fix.
Reproduction: https://stackblitz.com/edit/fg7exrjh?file=src%2FApp.tsx
Validation:
pnpm test:jsdom OTPFieldRoot --no-watchpnpm test:chromium OTPFieldRoot --no-watchpnpm test:jsdom OTPField --no-watchpnpm test:chromium OTPField --no-watchpnpm exec eslint packages/react/src/otp-field/root/OTPFieldRoot.tsx packages/react/src/otp-field/root/OTPFieldRoot.test.tsx --max-warnings 0pnpm exec prettier --check packages/react/src/otp-field/root/OTPFieldRoot.tsx packages/react/src/otp-field/root/OTPFieldRoot.test.tsx