Skip to content

[otp field] Prevent locked hidden autofill validation#4827

Merged
atomiks merged 4 commits into
mui:masterfrom
lunaxislu:fix/otp-field-hidden-input-validation-lock
May 18, 2026
Merged

[otp field] Prevent locked hidden autofill validation#4827
atomiks merged 4 commits into
mui:masterfrom
lunaxislu:fix/otp-field-hidden-input-validation-lock

Conversation

@lunaxislu
Copy link
Copy Markdown
Contributor

@lunaxislu lunaxislu commented May 15, 2026

Fixes #4828.

Follow-up to #4806 and #4810.

#4806 added a locked-state guard to OTP Field's hidden autofill input, but when the component is wrapped in Field.Root, the merged Field validation onChange can still run after the OTP Field handler returns. This can clear existing Form errors or commit validation while the field is readOnly or disabled.

This PR calls event.preventBaseUIHandler?.() before returning from the locked hidden-input autofill path, matching the Select, Combobox, and NumberField handling from #4810.

The tests now cover the locked-state matrix for hidden-input autofill:

  • readOnly / disabled
  • inside Field.Root / outside Field.Root

The outside-Field cases keep asserting that OTP Field public callbacks are not called. The inside-Field cases additionally assert that existing Field.Error content is preserved.

Verified with:

  • pnpm test:jsdom OTPField --no-watch
  • pnpm typescript

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 15, 2026

commit: 5095d90

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 15, 2026

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+28B(+0.01%) 🔺+2B(0.00%)

Details of bundle changes

Performance

Total duration: 1,336.12 ms +177.73 ms(+15.3%) | Renders: 50 (+0) | Paint: 2,050.49 ms +272.10 ms(+15.3%)

Test Duration Renders
Select mount (200 instances) 186.46 ms 🔺+40.25 ms(+27.5%) 3 (+0)
Menu mount (300 instances) 168.81 ms 🔺+32.13 ms(+23.5%) 2 (+0)
Mixed surface mount (app-like density) 92.10 ms 🔺+25.78 ms(+38.9%) 5 (+0)
Scroll Area mount (300 instances) 97.40 ms 🔺+16.51 ms(+20.4%) 3 (+0)
Select open (500 options) 59.96 ms 🔺+15.23 ms(+34.0%) 14 (+0)

…and 1 more (+6 within noise) — details


Check out the code infra dashboard for more information about this PR.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 5095d90
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a0aa4af3f902800085fcd40
😎 Deploy Preview https://deploy-preview-4827--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

@atomiks atomiks left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @lunaxislu

@atomiks atomiks added type: bug It doesn't behave as expected. component: otp field labels May 18, 2026
@atomiks atomiks merged commit 4a339d0 into mui:master May 18, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: otp field type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[otp field] Field validation runs after locked hidden-input autofill

2 participants