Skip to content

[field][checkbox][switch] Fix controlled blur validation and stale filled state - #5563

Merged
atomiks merged 8 commits into
mui:masterfrom
atomiks:fix/field-blur-filled-state
Aug 25, 2026
Merged

[field][checkbox][switch] Fix controlled blur validation and stale filled state#5563
atomiks merged 8 commits into
mui:masterfrom
atomiks:fix/field-blur-filled-state

Conversation

@atomiks

@atomiks atomiks commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Two field lifecycle fixes. The blur half is a regression from #5460; the filled half predates it.

  • Controlled blur normalization no longer discards validation. With validationMode="onBlur", a blur handler that normalizes the controlled value (e.g. .trim()) had its commit retired by the value's prop transition. The blur handler now re-commits the settled DOM value in a microtask, unless it settled back to the initial value (a programmatic reset stays quiet). Async normalization after blur is still not covered.
  • filled is now derived from the current value in a layout effect (the NumberField pattern) instead of transition callbacks and write-only mount effects. This fixes stale data-filled on remounts and custom render elements in Field.Control, Checkbox.Root, and Switch.Root, and CheckboxGroup now fully owns the filled state.

dirty stays transition-driven: deriving it needs mount-time initialValue ordering guarantees and interacts with #5345.

@atomiks atomiks added component: switch Changes related to the switch component. type: bug It doesn't behave as expected. component: checkbox Changes related to the checkbox component. component: field Changes related to the field component. labels Aug 25, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 25, 2026

Copy link
Copy Markdown

commit: 51bc501

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 25, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+122B(+0.03%) 🔺+45B(+0.03%)

Details of bundle changes

Performance

Total duration: 1,103.23 ms -27.01 ms(-2.4%) | Renders: 76 (+0) | Paint: 1,790.28 ms -55.89 ms(-3.0%)

Test Duration Renders
Combobox open — 500 items 30.39 ms 🔺+5.12 ms(+20.3%) 4 (+0)

14 tests within noise — details


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

@netlify

netlify Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 51bc501
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a8d54649cc8fc0008eb8572
😎 Deploy Preview https://deploy-preview-5563--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 force-pushed the fix/field-blur-filled-state branch from 7348abe to 2999b2c Compare August 25, 2026 07:41
@atomiks
atomiks marked this pull request as ready for review August 25, 2026 08:47
@atomiks
atomiks merged commit 1e208a9 into mui:master Aug 25, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: checkbox Changes related to the checkbox component. component: field Changes related to the field component. component: switch Changes related to the switch component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant