Skip to content

[card] Remove deprecated CardHeader props#47995

Merged
silviuaavram merged 4 commits intomui:masterfrom
silviuaavram:chore/remove-deprecated-props-6
Mar 24, 2026
Merged

[card] Remove deprecated CardHeader props#47995
silviuaavram merged 4 commits intomui:masterfrom
silviuaavram:chore/remove-deprecated-props-6

Conversation

@silviuaavram
Copy link
Member

@silviuaavram silviuaavram commented Mar 16, 2026

Copilot AI review requested due to automatic review settings March 16, 2026 15:48
@silviuaavram silviuaavram added breaking change Introduces changes that are not backward compatible. scope: card Changes related to the card. 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 labels Mar 16, 2026
@mui-bot
Copy link

mui-bot commented Mar 16, 2026

Netlify deploy preview

Bundle size report

Bundle Parsed size Gzip size
@mui/material ▼-75B(-0.01%) ▼-7B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against e4564fd

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes the deprecated CardHeader props (titleTypographyProps / subheaderTypographyProps) and updates the implementation, TypeScript types, type tests, and documentation to rely on slotProps instead (including adding an upgrade-to-v9 migration note).

Changes:

  • Removed deprecated props from CardHeader runtime implementation and PropTypes.
  • Removed deprecated props (and related generics) from CardHeader TypeScript definitions.
  • Updated type tests and API docs JSON, and added a v9 migration snippet/codemod pointer.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/mui-material/src/CardHeader/CardHeader.spec.tsx Replaces deprecated prop type tests with slotProps-based tests (currently has several missing @ts-expect-error annotations).
packages/mui-material/src/CardHeader/CardHeader.js Removes deprecated prop handling and PropTypes entries (note: removed prop names may now leak via ...other).
packages/mui-material/src/CardHeader/CardHeader.d.ts Removes deprecated props and related generics from public TS types.
docs/translations/api-docs/card-header/card-header.json Removes deprecated prop entries from translated API docs.
docs/pages/material-ui/api/card-header.json Removes deprecated prop entries from the generated API docs page JSON.
docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md Adds migration guidance and codemod command for the removed CardHeader props.
Comments suppressed due to low confidence (1)

packages/mui-material/src/CardHeader/CardHeader.js:88

  • After removing titleTypographyProps / subheaderTypographyProps from the destructuring, those props will now remain in ...other and end up being forwarded to the root slot (as unknown DOM attributes) if consumers still pass them. Consider explicitly destructuring and discarding these removed props (without supporting them) to avoid leaking them to the DOM and triggering React unknown-prop warnings.
  const {
    action,
    avatar,
    component = 'div',
    disableTypography = false,
    subheader: subheaderProp,
    title: titleProp,
    slots = {},
    slotProps = {},
    ...other
  } = props;

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

You can also share your feedback on Copilot code review. Take the survey.

@oliviertassinari oliviertassinari changed the title [cardheader] Remove deprecated props [card] Remove deprecated CardHeader props Mar 17, 2026
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 17, 2026
@silviuaavram silviuaavram force-pushed the chore/remove-deprecated-props-6 branch from 36354a8 to 1398df1 Compare March 17, 2026 12:14
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Mar 17, 2026
Comment on lines 205 to -218
export type CardHeaderProps<
RootComponent extends React.ElementType = CardHeaderTypeMap['defaultComponent'],
AdditionalProps = {},
TitleTypographyComponent extends React.ElementType = 'span',
SubheaderTypographyComponent extends React.ElementType = 'span',
> = OverrideProps<
CardHeaderTypeMap<
AdditionalProps,
RootComponent,
TitleTypographyComponent,
SubheaderTypographyComponent
>,
RootComponent
>;
Copy link
Member

Choose a reason for hiding this comment

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

We should add this also in the migration guide that CardHeaderProps does not support these two generic parameters now (Use slotProps). Because CardHeaderProps is a public TS type.

Comment on lines +116 to +119
// @ts-expect-error
titleTypographyProps: true,
slotProps: {
title: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

How come title slot props support boolean?

Copy link
Member

Choose a reason for hiding this comment

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

From Claude Code:

Slot prop types resolve through SlotComponentProps to Partial<ComponentPropsWithRef<T>> & TOverrides. When TOverrides is an empty override interface like CardHeaderTitleSlotPropsOverrides (designed for module augmentation), the intersection simplifies to Partial<ComponentPropsWithRef<T>> — a type where every property is optional. In TS, primitives like true are assignable to any type where all properties are optional, because there are no required properties to violate.

The suggested fix is to add & object to

| (Partial<React.ComponentPropsWithRef<TSlotComponent>> & TOverrides)

so it becomes (Partial<React.ComponentPropsWithRef<TSlotComponent>> & TOverrides & object)

Unlike & any which destroys all type info, & object preserves autocomplete and property checking — it only adds "must be non-primitive." This is exactly what the object type was designed for. The fix is a 2-line change in SlotComponentProps and SlotComponentPropsWithSlotState in mui-utils.

Copy link
Member

Choose a reason for hiding this comment

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

Fix suggested can be considered.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this related to the migration PR? Or something extra we need to do? I'm OK adding it here but just wanted to make sure we're not extending scope that much.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to do this change separately so it's easier to isolate if something backfires ~

Copy link
Member

Choose a reason for hiding this comment

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

This test should be removed? titleTypographyProps is not valid anymore.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 19, 2026
},
}}
/>;
// @ts-expect-error
Copy link
Member

Choose a reason for hiding this comment

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

this should not be removed?

Comment on lines +116 to +119
// @ts-expect-error
titleTypographyProps: true,
slotProps: {
title: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

This test should be removed? titleTypographyProps is not valid anymore.

@silviuaavram silviuaavram force-pushed the chore/remove-deprecated-props-6 branch from 1398df1 to b18d040 Compare March 23, 2026 15:13
@silviuaavram silviuaavram merged commit 00a8186 into mui:master Mar 24, 2026
23 checks passed
@silviuaavram silviuaavram deleted the chore/remove-deprecated-props-6 branch March 24, 2026 08:14
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. scope: card Changes related to the card. 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