Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui] Fix slotProps.transition types #45214

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Feb 5, 2025

closes #45210

Root cause

The existing slotProps below for transition is not correct:

transition: SlotProps<
  React.ElementType<TransitionProps>,
  DialogTransitionSlotPropsOverrides,
  DialogOwnerState
>;

It's because TransitionProps extends React.HTMLAttributes<HTMLElement> that causes the final types to be a union of TransitionProps and HTML props. That's why transition['onExited'] does not exist, see this TypeScript playground

This PR fixes the issue by moving TransitionProps to the second parameter (the TOverrides).

All slotProps.transition should follow:

   transition: SlotComponentProps<
      React.ElementType,
      TransitionProps & DialogTransitionSlotPropsOverrides,
      DialogOwnerState
    >;

The SlotComponentProps must be used instead of SlotProps because transition slot does not support component and sx prop.


@siriwatknp siriwatknp changed the title Fix/transition slot props [material-ui] Fix slotProps.transition types Feb 5, 2025
@siriwatknp siriwatknp added typescript package: material-ui Specific to @mui/material labels Feb 5, 2025
@mui-bot
Copy link

mui-bot commented Feb 5, 2025

Netlify deploy preview

https://deploy-preview-45214--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against ce677e0

Copy link
Member

@aarongarciah aarongarciah left a comment

Choose a reason for hiding this comment

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

Looks good. Left a question. I'll let @DiegoAndai do another pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrating from 'TransitionProps' to 'slotProps.transition' cause TS type inference error
3 participants