Skip to content

[fields] Remove enableAccessibleFieldDOMStructure behavior#21966

Merged
LukasTy merged 62 commits into
mui:masterfrom
LukasTy:fields-remove-accessible-dom-structure
Apr 7, 2026
Merged

[fields] Remove enableAccessibleFieldDOMStructure behavior#21966
LukasTy merged 62 commits into
mui:masterfrom
LukasTy:fields-remove-accessible-dom-structure

Conversation

@LukasTy
Copy link
Copy Markdown
Member

@LukasTy LukasTy commented Apr 2, 2026

Summary

Removes the enableAccessibleFieldDOMStructure prop from all pickers and field components. The accessible DOM structure (section-based PickersTextField) introduced in v7 is now the only supported mode — the legacy v6 plain <input> fallback is no longer available.

What changed

  • Deleted useFieldV6TextField hook and all v6 legacy field rendering code
  • Removed TEnableAccessibleFieldDOMStructure generic parameter from PickerManager, all field/picker types, hooks, and components
  • Simplified core field hooks (useField, useFieldState, buildSectionsFromFormat, getSectionOrder) by removing all conditional v6/v7 branching
  • Inlined useFieldV7TextField into useField and useFieldRootHandleKeyDown into useFieldRootProps (no longer need separate files)
  • Removed createDateStrForV6InputFromSections / getV6InputValueFromSections from value managers
  • Renamed getV7HiddenInputValueFromSectionsgetHiddenInputValueFromSections
  • Removed UseDateManagerParameters and UseDateTimeManagerParameters interfaces (were empty after prop removal)
  • Deleted e2e fixtures and docs for NonAccessibleDOMStructure variants
  • Renamed BrowserV7* and MaterialV7* demo files to drop "V7" suffix
  • Renamed expectFieldValueV7expectFieldValue and v7Responseresponse in test utilities
  • Added deprecation notices in v6 and v7 migration guides
  • Added remove-enable-accessible-field-dom-structure codemod (v9.0.0) that strips the prop from all JSX usages; included in preset-safe
  • Updated v8 migration guide with codemods section and removed types documentation

@LukasTy LukasTy self-assigned this Apr 2, 2026
@LukasTy LukasTy added breaking change Introduces changes that are not backward compatible. scope: pickers Changes related to the date/time pickers. labels Apr 2, 2026
Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

Can you update the merge conflict and I'll review it again.
Just want to make sure that the PickerUIField is up-to-date with master from my earlier PR.

@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Apr 6, 2026
@LukasTy
Copy link
Copy Markdown
Member Author

LukasTy commented Apr 6, 2026

Can you update the merge conflict and I'll review it again. Just want to make sure that the PickerUIField is up-to-date with master from my earlier PR.

Addressed conflicts. 👌


@flaviendelangle, I've addressed valid concerns in: #21966 (review).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Apr 6, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Apr 6, 2026
@LukasTy
Copy link
Copy Markdown
Member Author

LukasTy commented Apr 6, 2026

Code Review: PR #21966 — Remove enableAccessibleFieldDOMStructure behavior

Overview

Removes the enableAccessibleFieldDOMStructure prop and all v6 legacy field rendering code, making the v7 accessible DOM structure (section-based PickersSectionList) the only mode. Includes a codemod, migration guide updates, and comprehensive test/type cleanup.

Overall: well-executed removal. The diff is large but consistent. Below are edge cases and risks focused on user-facing breakage.


Edge Cases & Risks

1. Codemod doesn't cover slotProps.field usage (Medium Risk)

The codemod only strips enableAccessibleFieldDOMStructure as a direct JSX prop. Users who passed it inside slotProps.field objects will NOT be auto-migrated:

// NOT handled by codemod — will cause TS error but no auto-fix
<DatePicker slotProps={{ field: { enableAccessibleFieldDOMStructure: false } }} />

Suggestion: Either extend the codemod to handle object properties inside slotProps.field, or explicitly call this out in the migration guide as a manual step.

2. Codemod can't handle spread props (Low Risk, but worth documenting)

const fieldProps = { enableAccessibleFieldDOMStructure: true };
<DateField {...fieldProps} />  // codemod won't catch this

This is inherently hard for codemods. Just note it in the migration guide.

3. Removed generic type parameter TEnableAccessibleFieldDOMStructure (Medium Risk)

All picker/field type interfaces lose their first generic parameter. Any user code that explicitly parameterized these will break:

// Before (compiles)
const props: DateRangePickerProps<boolean> = ...;
useDateField<true, typeof props>(props);

// After (TS error)
const props: DateRangePickerProps = ...;
useDateField<typeof props>(props);

No codemod covers this. The migration guide should list the affected types explicitly:

  • All *PickerProps, *FieldProps, *SlotProps generics
  • PickerManager (5 → 4 type params)
  • useDateField, useDateTimeField, etc. hook generics

4. Removed public type exports (Medium Risk)

These public exports are removed without codemod coverage:

  • UseDateManagerParameters, UseDateTimeManagerParameters — deleted entirely
  • PickerManagerEnableAccessibleFieldDOMStructure — removed from internals exports
  • createDateStrForV6InputFromSections — removed (renamed counterpart: createDateStrForHiddenInputFromSections)
  • getV6InputValueFromSections removed from FieldValueManager interface

Users with custom field implementations that imported these will get hard build failures. Consider adding the renamed exports to the migration guide.

5. Custom textField slot with plain <input> (Medium Risk — good error, but abrupt)

Users who had enableAccessibleFieldDOMStructure={false} with a custom plain <input> in the textField slot will now hit error code 205 at runtime. The error message is clear, but this is a runtime crash rather than a compile-time error. The migration guide does mention this, but it's worth highlighting it more prominently since it's the most likely "silent v8 → v9 breakage" scenario.

6. TODO: Remove v9 comment in PickerFieldUI.tsx (Nit)

There's a TODO: Remove v9 - temporary workaround comment — but this PR is for v9. Should this be addressed now or relabeled?


What's Done Well

  • Runtime dev warning: Passing the removed prop emits warnOnce in dev mode rather than crashing — correct DX for a removed prop.
  • Error 205 safety net: Good guard against users who passed plain <input> to textField slot (only worked with v6 mode).
  • Clean removal: No leftover v6/v7 conditional branches in core hooks. useField, buildSectionsFromFormat, getSectionOrder are all cleanly simplified.
  • Test coverage: No gaps found. V6-only tests removed; remaining tests cover the now-only accessible structure.
  • Codemod + preset-safe integration: Properly wired into the v9.0.0 preset-safe pipeline.
  • Renames consistent: V7 suffix dropped from all file names, test helpers, and utility functions.

Suggestions

  1. Extend codemod to strip enableAccessibleFieldDOMStructure from slotProps.field object properties, or document it as a manual migration step.
  2. Add a "Removed Types" section to the migration guide listing all deleted/renamed type exports.
  3. Highlight the runtime error 205 scenario more prominently in the migration guide — users with custom plain <input> textField slots will crash at runtime.
  4. Resolve or relabel the TODO: Remove v9 in PickerFieldUI.tsx.

Copy link
Copy Markdown
Member Author

@LukasTy LukasTy Apr 6, 2026

Choose a reason for hiding this comment

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

Contents directly moved to useField/useFieldRootProps.ts

Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍

@siriwatknp siriwatknp mentioned this pull request Apr 7, 2026
1 task
@LukasTy LukasTy merged commit 7d068b2 into mui:master Apr 7, 2026
21 checks passed
@LukasTy LukasTy deleted the fields-remove-accessible-dom-structure branch April 7, 2026 05:30
LukasTy added a commit to LukasTy/mui-x that referenced this pull request Apr 17, 2026
These were leftovers from the v6/v7 field DOM structure era (removed in mui#21966) where each test rendered twice and called unmount() between renders. Vitest's auto-cleanup (`afterEach(() => cleanup())` registered in `@mui/internal-test-utils/setupVitest`) already handles teardown between tests, so the trailing calls are redundant.

The three `testFormat` helpers in the Desktop picker field tests are intentionally left alone since they render multiple times within a single it() block and the intermediate unmount is load-bearing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
arminmeh pushed a commit to arminmeh/mui-x that referenced this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. feature: Keyboard editing Related to the pickers keyboard edition scope: pickers Changes related to the date/time pickers. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. v9.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants