Skip to content

[otp field] Ignore hidden-input changes while readonly or disabled#4806

Merged
atomiks merged 2 commits into
mui:masterfrom
lunaxislu:fix/otp-field-hidden-input-autofill-lock-state
May 11, 2026
Merged

[otp field] Ignore hidden-input changes while readonly or disabled#4806
atomiks merged 2 commits into
mui:masterfrom
lunaxislu:fix/otp-field-hidden-input-autofill-lock-state

Conversation

@lunaxislu
Copy link
Copy Markdown
Contributor

Fixes #4805

Summary

OTPField.Input already ignores changes while the field is readOnly or disabled, but the hidden validation input rendered by OTPField.Root still accepted change events.

This patch applies the same guard to the hidden input's onChange handler so locked OTP fields cannot be updated through that path.

Why

There is already existing coverage for hidden-input autofill, so this aligns the locked-state behavior across both input paths instead of changing the intended hidden-input flow.

Changes

  • add disabled || readOnly guard to the hidden validation input onChange
  • add a regression test for readonly hidden-input autofill
  • add a regression test for disabled hidden-input autofill

Testing

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

commit: 4c2ede3

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 11, 2026

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+6B(0.00%) 🔺+7B(0.00%)

Details of bundle changes

Performance

Total duration: 1,068.37 ms ▼-129.45 ms(-10.8%) | Renders: 50 (+0) | Paint: 1,622.77 ms ▼-207.21 ms(-11.3%)

Test Duration Renders
Select mount (200 instances) 144.44 ms 🔺+0.31 ms(+0.2%) 3 (+0)
Tabs mount (200 instances) 202.62 ms ▼-26.52 ms(-11.6%) 4 (+0)
Menu mount (300 instances) 120.60 ms ▼-23.19 ms(-16.1%) 2 (+0)
Menu open (500 items) 58.95 ms ▼-16.03 ms(-21.4%) 12 (+0)
Scroll Area mount (300 instances) 79.32 ms ▼-13.85 ms(-14.9%) 3 (+0)

…and 7 more — details


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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 11, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f2e3843
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a019f02765860000859a47a
😎 Deploy Preview https://deploy-preview-4806--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 11, 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] Hidden validation input still accepts changes while readOnly or disabled

2 participants