Skip to content

[field][form][fieldset] Reduce bundle size - #5225

Merged
atomiks merged 4 commits into
mui:masterfrom
atomiks:claude/base-ui-form-simplifications-894bcc
Jul 13, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
atomiks:claude/base-ui-form-simplifications-894bcc

Conversation

@atomiks

@atomiks atomiks commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Removes dead and redundant code from Field, Form, and Fieldset. The bundle bot is authoritative for the current size impact.

The previously ineffective only-valueMissing revalidation bail now works as intended, deferring stale coexisting errors until blur or submit; FieldValidity regression tests pin this behavior.

@atomiks atomiks added component: form Changes related to the form component. component: field Changes related to the field component. internal Behind-the-scenes enhancement. Formerly called “core”. component: fieldset labels Jul 13, 2026
@pkg-pr-new

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

commit: db9892c

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-703B(-0.16%) ▼-220B(-0.15%)

Details of bundle changes

Performance

Total duration: 1,256.94 ms -76.39 ms(-5.7%) | Renders: 78 (+0) | Paint: 1,949.55 ms -122.27 ms(-5.9%)

Test Duration Renders
Select mount (200 instances) 141.75 ms ▼-50.00 ms(-26.1%) 3 (+0)
Select open (500 options) 40.45 ms ▼-13.75 ms(-25.4%) 14 (+0)

12 tests within noise — details


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

@netlify

netlify Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit db9892c
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a54f720cdec4b0008c3c1a0
😎 Deploy Preview https://deploy-preview-5225--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] Reduce field, form, and fieldset bundle size [field][form][fieldset] Reduce bundle size Jul 13, 2026
@atomiks atomiks added performance and removed internal Behind-the-scenes enhancement. Formerly called “core”. labels Jul 13, 2026
@atomiks
atomiks force-pushed the claude/base-ui-form-simplifications-894bcc branch from 3518aef to 0bdd1e5 Compare July 13, 2026 09:25
@atomiks
atomiks marked this pull request as ready for review July 13, 2026 09:29
@atomiks
atomiks requested a review from Copilot July 13, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces shipped bundle size across the Field/Form/Fieldset family by removing redundant internal code paths and simplifying registration/validation logic while aiming to keep behavior unchanged (and adding regression tests for key flows).

Changes:

  • Simplifies internal registration/ID plumbing (moving to useRefWithInit, ref-based field ID tracking, and trimming FieldRootContext surface area).
  • Refactors <Form /> submission/focus behavior to focus the first invalid control consistently and streamlines error clearing / form value collection.
  • Adjusts field validation logic around native validity revalidation and adds tests to cover the updated behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/react/src/internals/labelable-provider/useLabelableId.ts Removes the Symbol description string to reduce bytes.
packages/react/src/internals/field-root-context/FieldRootContext.ts Trims unused context fields/defaults to reduce dead exports and surface area.
packages/react/src/internals/field-register-control/useRegisterFieldControl.ts Uses useRefWithInit for stable per-control symbols and simplifies guards/deps.
packages/react/src/internals/field-register-control/useFieldControlRegistration.ts Removes fallback refs and switches registered field ID tracking to a ref.
packages/react/src/form/Form.tsx Refactors submit/focus flow and error handling; uses Object.hasOwn for own-property checks.
packages/react/src/form/Form.test.tsx Adds coverage for focusing first invalid field, external error replacement, and Strict Mode registration targeting.
packages/react/src/fieldset/root/FieldsetRootContext.ts Tightens context typing for disabled to always be boolean.
packages/react/src/fieldset/legend/FieldsetLegend.tsx Aligns legend state with new non-optional disabled context value.
packages/react/src/field/validity/FieldValidity.tsx Documents memoization rationale for the render-prop state object identity.
packages/react/src/field/validity/FieldValidity.test.tsx Adds coverage for deferring stale custom errors across validation boundaries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react/src/form/Form.tsx Resolved
Comment thread packages/react/src/form/Form.test.tsx Resolved
@atomiks
atomiks force-pushed the claude/base-ui-form-simplifications-894bcc branch from d8e0274 to db9892c Compare July 13, 2026 14:33
@atomiks
atomiks merged commit 9b2f7f2 into mui:master Jul 13, 2026
7 checks passed
@atomiks
atomiks deleted the claude/base-ui-form-simplifications-894bcc branch August 11, 2026 03:01
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. component: fieldset component: form Changes related to the form component. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants