Skip to content

[fieldset] Fix disabled fieldset form bugs - #4890

Merged
atomiks merged 9 commits into
mui:masterfrom
atomiks:codex/fix-fieldset-disabled-form
May 25, 2026
Merged

atomiks merged 9 commits into
mui:masterfrom
atomiks:codex/fix-fieldset-disabled-form

Conversation

@atomiks

@atomiks atomiks commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

This is part of the Codex component behavior and test coverage sweep. It fixes Fieldset/Form disabled-state bugs found during review and adds focused test coverage for the affected paths.

Disabled field-aware controls now follow native HTML disabled semantics more broadly: whether disabled directly, through Field.Root, or through Fieldset.Root, they are skipped by Base UI Form validation and omitted from onFormSubmit values.

Changes

  • Preserve native disabled semantics on Fieldset.Root, including nested fieldsets and render-prop compositions.
  • Stop disabled fieldset and individually disabled field-aware controls from registering with Base UI Form validation and submission.
  • Make the Fieldset.Legend missing-root guard reachable.
  • Add coverage for disabled fieldsets, field-aware controls, Form submit values, and Legend root usage.

Original findings addressed

  • [P1] <Fieldset.Root disabled> drops the native disabled attribute.
  • [P1] Fieldset-disabled Field controls still participate in Base UI Form validation and submission.
  • [P2] disabled does not flow through documented Fieldset render compositions.
  • [P2] Nested Base UI fieldsets can shadow an outer disabled fieldset.
  • [P3] The missing-root guard for Fieldset.Legend is dead code.

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

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

commit: 42a154a

@code-infra-dashboard

code-infra-dashboard Bot commented May 22, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+222B(+0.05%) 🔺+114B(+0.08%)

Details of bundle changes

Performance

Total duration: 1,322.54 ms -67.26 ms(-4.8%) | Renders: 50 (+0) | Paint: 2,000.10 ms -103.39 ms(-4.9%)

Test Duration Renders
Checkbox mount (500 instances) 116.88 ms 🔺+44.90 ms(+62.4%) 1 (+0)

11 tests within noise — details


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

@netlify

netlify Bot commented May 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 42a154a
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a143dc7dd37fe00085a8bc5
😎 Deploy Preview https://deploy-preview-4890--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 added component: fieldset and removed component: form Changes related to the form component. component: field Changes related to the field component. labels May 22, 2026
@atomiks atomiks changed the title [field] Fix disabled fieldset form bugs [fieldset] Fix disabled fieldset form bugs May 22, 2026
@atomiks
atomiks marked this pull request as ready for review May 22, 2026 11:55
@atomiks

atomiks commented May 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Code Review (GPT-5.5 + Opus 4.7)

Approve ✅: the current branch fixes the Fieldset/Form disabled-state bugs without introducing actionable issues, and the broader disabled-control behavior is now documented in the PR body.

1. Bugs / Issues (None)

No concrete blocking or non-blocking issues found in the full diff against refreshed upstream/master.

Root Cause & Patch Assessment

The fix is targeted at the right ownership points. Fieldset.Root now preserves native disabled semantics, nested fieldsets inherit disabled state through context, and Field.Root consumes the Fieldset context optionally so fields outside a fieldset keep working.

Changing FieldsetRootContext to default to undefined also makes the Fieldset.Legend missing-root guard reachable instead of silently using a no-op context. The remaining non-optional consumer is the intended throwing path.

The Form registration changes are consistent across the affected field-aware controls: disabled controls stop registering with the Base UI Form validation map, which excludes them from validation and onFormSubmit values in line with native disabled-control behavior.

Pattern Consistency Assessment

All touched useRegisterFieldControl call sites now gate registration on the resolved disabled state, while preserving the existing group-specific conditions such as !groupContext and !!fieldName. The resolved disabled state flows through the existing Field/Fieldset ownership chain, so the implementation stays centralized instead of adding Form-specific filtering later in submission.

Opus Notes

Opus called out that the behavior change is broader than fieldsets: individually disabled field-aware controls are also excluded from Form validation and submitted values. That is native-aligned and is now called out in the PR body, so I do not see a remaining documentation issue.

Opus also noted the synchronous Fieldset.Legend throw test differs from an async .rejects.toThrow() pattern used elsewhere. The test passes in the targeted suite and is asserting the render-phase error directly, so I would not block on changing it.

Test Coverage Assessment

Validation run on the current PR head:

  • pnpm test:jsdom Fieldset --no-watch
  • pnpm test:jsdom Form --no-watch
  • pnpm typescript

The focused coverage exercises native Fieldset disabled semantics, nested fieldsets, render-prop disabled propagation, Form submit values, and the Legend missing-root guard. I do not see a remaining coverage gap that needs to block this PR.

@atomiks
atomiks merged commit c779f6b into mui:master May 25, 2026
6 checks passed
@atomiks
atomiks deleted the codex/fix-fieldset-disabled-form branch May 25, 2026 12:22
mbrookes pushed a commit to mbrookes/base-ui that referenced this pull request May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: fieldset type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant