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

atomiks merged 4 commits into
mui:masterfrom
lunaxislu:fix/otp-field-hidden-input-validation-lock

Conversation

@lunaxislu

@lunaxislu lunaxislu commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

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

pkg-pr-new Bot commented May 15, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4827
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4827
    

commit: 5095d90

@code-infra-dashboard

code-infra-dashboard Bot commented May 15, 2026 •

Copy link
Copy Markdown

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

netlify Bot commented May 15, 2026 •

Copy link
Copy Markdown

✅ 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.

@atomiks atomiks left a comment

Copy link
Copy Markdown
Contributor

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
6 checks passed
mbrookes pushed a commit to mbrookes/base-ui that referenced this pull request May 25, 2026
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