Skip to content

[field] Don't warn when an uncontrolled FieldControl's defaultValue changes - #5881

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:field-control-default-value
Oct 6, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:field-control-default-value

Conversation

@atomiks

@atomiks atomiks commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #5880

Field.Control passed defaultValue to useControlled, which warns when the default changes after mount. The hook's stored value was only read for controlled fields, though. Uncontrolled fields already forward the current defaultValue to the native input, so a changing default works the same as on a plain <input>, and the warning was wrong.

Changes

  • This PR removes useControlled from FieldControl. Its only other job was the controlled ↔ uncontrolled switch warning, which React DOM already logs because we pass either value or defaultValue to the input.
  • This PR also re-syncs data-filled when defaultValue changes. Before the user types, React updates the input's value along with the default, but the filled state stayed stale.

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

pkg-pr-new Bot commented Oct 5, 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@5881
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5881
    

commit: 4dc7f7d

@code-infra-dashboard

code-infra-dashboard Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-77B(-0.01%) ▼-23B(-0.01%)

Details of bundle changes

Performance

Total duration: 428.71 ms -5.59 ms(-1.3%) | Renders: 76 (+0) | Paint: 794.34 ms -4.06 ms(-0.5%)

No significant changes — details


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

@netlify

netlify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 4dc7f7d
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6ac483420642ca0008a1bc13
😎 Deploy Preview https://deploy-preview-5881--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 marked this pull request as ready for review October 5, 2026 05:36
@atomiks
atomiks force-pushed the field-control-default-value branch from 3492d53 to 4dc7f7d Compare October 6, 2026 05:12
@atomiks
atomiks merged commit fa6c17d into mui:master Oct 6, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[field] FieldControl warns about a changing defaultValue that it already handles correctly

1 participant