Skip to content

[field] Fix custom validity ownership and validation lifecycle - #5449

Merged
atomiks merged 11 commits into
mui:masterfrom
atomiks:claude/affectionate-cannon-280eb4
Aug 12, 2026
Merged

atomiks merged 11 commits into
mui:masterfrom
atomiks:claude/affectionate-cannon-280eb4

Conversation

@atomiks

@atomiks atomiks commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Establishes explicit ownership of the setCustomValidity messages the field installs, and fixes four validation bugs that trace back to the missing ownership model. First of a series from a full review of the Form/Field module.

Changes

  • The field records each custom validity message it installs (per input, matched on normalized text) and retires its own residue at the start of every validation pass. Previously the stale message read back through element.validationMessage as if it were a native constraint, so with validationMode="onBlur" a cross-field validator (confirm password) never re-ran on submit and the form stayed blocked until the user retyped in that field.
  • Messages set outside the field are preserved: the field never clears them, restores a message its own error displaced once that error resolves, and treats an overwrite or withdrawal by outside code as an ownership transfer. This supersedes [field] Preserve custom validity set outside the field #5348: it covers the same scenario and fixes the gaps flagged in its review, including ownership on inputs barred from constraint validation (disabled or readonly), where validationMessage is unreadable.
  • Validator results are normalized once: null, undefined, '', and [] are valid. validate={() => []} previously marked the field invalid with an empty visible Field.Error and a permanently blocked submit.
  • Published validity is built in one place, so valid: true can no longer coexist with a non-empty errors array (previously observable through Field.Validity for a pristine required field in onBlur mode).
  • Pending validation dies with its control: a debounced or async validation is canceled when the registered control unmounts or is replaced, and starting an async validation synchronously retires the previous result from the form registry so a stale error cannot block submission (async validation is documented not to block it).

Notes

Two existing tests depended on the []/undefined bug to keep their forms from actually submitting in the browser test env. They now call preventDefault explicitly, matching their intent (asserting formValues).

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

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

commit: 555bed6

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+304B(+0.07%) 🔺+122B(+0.08%)

Details of bundle changes

Performance

Total duration: 1,225.02 ms +6.46 ms(+0.5%) | Renders: 76 (+0) | Paint: 1,912.34 ms -7.84 ms(-0.4%)

Test Duration Renders
Popover mount (300 instances) 79.17 ms 🔺+21.71 ms(+37.8%) 1 (+0)

14 tests within noise — details

Metric alarms

Test Metric Change
Popover mount (300 instances) bench:paint 🔺 +27.49 ms

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

@netlify

netlify Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 555bed6
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a7c5c3e9c6c920008319d54
😎 Deploy Preview https://deploy-preview-5449--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 changed the title [field] Fix custom validity ownership and validation lifecycle bugs [field] Fix custom validity ownership and validation lifecycle Aug 12, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Aug 12, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Aug 12, 2026
@atomiks
atomiks marked this pull request as ready for review August 12, 2026 11:43
@atomiks
atomiks merged commit bb1d990 into mui:master Aug 12, 2026
6 checks passed
@atomiks
atomiks deleted the claude/affectionate-cannon-280eb4 branch August 12, 2026 11:52
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.

1 participant