Skip to content

[otp field] Prevent locked hidden autofill validation#4827

Open
lunaxislu wants to merge 1 commit into
mui:masterfrom
lunaxislu:fix/otp-field-hidden-input-validation-lock
Open

[otp field] Prevent locked hidden autofill validation#4827
lunaxislu wants to merge 1 commit 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: 08b9bfe

@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%) 🔺+18B(+0.01%)

Details of bundle changes

Performance

Total duration: 1,007.49 ms ▼-438.43 ms(-30.3%) | Renders: 50 (+0) | Paint: 1,514.09 ms ▼-674.76 ms(-30.8%)

Test Duration Renders
Tabs mount (200 instances) 200.26 ms ▼-73.88 ms(-26.9%) 4 (+0)
Select mount (200 instances) 115.06 ms ▼-56.32 ms(-32.9%) 3 (+0)
Slider mount (300 instances) 136.33 ms ▼-55.71 ms(-29.0%) 3 (+0)
Menu mount (300 instances) 107.55 ms ▼-48.68 ms(-31.2%) 2 (+0)
Scroll Area mount (300 instances) 75.68 ms ▼-45.87 ms(-37.7%) 3 (+0)

…and 5 more (+2 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!

Built without sensitive environment variables

Name Link
🔨 Latest commit 08b9bfe
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a073e1e39f16f00080eb951
😎 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.

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.

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

1 participant