Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,23 @@ If you render a `TextField` from `Autocomplete`, the `params` shape also changed
)}
/>
```

#### Accordion deprecated props removed

Use the [accordion-props codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#accordion-props) below to migrate the code as described in the following section:

```bash
npx @mui/codemod@latest deprecations/accordion-props <path>
```

The deprecated `Accordion` props have been removed.
Use the `slots` and `slotProps` props instead:

```diff
<Accordion
- TransitionComponent={CustomTransition}
- TransitionProps={{ unmountOnExit: true }}
+ slots={{ transition: CustomTransition }}
+ slotProps={{ transition: { unmountOnExit: true } }}
>
```
10 changes: 0 additions & 10 deletions docs/pages/material-ui/api/accordion.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"TransitionComponent": {
"type": { "name": "elementType" },
"deprecated": true,
"deprecationInfo": "Use <code>slots.transition</code> instead. This prop will be removed in a future major release. See <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
},
"TransitionProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.transition</code> instead. This prop will be removed in a future major release. See <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
}
},
"name": "Accordion",
Expand Down
6 changes: 0 additions & 6 deletions docs/translations/api-docs/accordion/accordion.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
"slots": { "description": "The components used for each slot inside." },
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"TransitionComponent": {
"description": "The component used for the transition. <a href=\"https://mui.com/material-ui/transitions/#transitioncomponent-prop\">Follow this guide</a> to learn more about the requirements for this component."
},
"TransitionProps": {
"description": "Props applied to the transition element. By default, the element is based on this <a href=\"https://reactcommunity.org/react-transition-group/transition/\"><code>Transition</code></a> component."
}
},
"classDescriptions": {
Expand Down
16 changes: 0 additions & 16 deletions packages/mui-material/src/Accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,6 @@ export interface AccordionOwnProps {
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The component used for the transition.
* [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
* @deprecated Use `slots.transition` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*/
TransitionComponent?:
| React.JSXElementConstructor<
TransitionProps & { children?: React.ReactElement<unknown, any> | undefined }
>
| undefined;
/**
* Props applied to the transition element.
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
* @deprecated Use `slotProps.transition` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*/
TransitionProps?: TransitionProps | undefined;
}

export type AccordionTypeMap<
Expand Down
21 changes: 2 additions & 19 deletions packages/mui-material/src/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ const Accordion = React.forwardRef(function Accordion(inProps, ref) {
onChange,
slots = {},
slotProps = {},
TransitionComponent: TransitionComponentProp,
TransitionProps: TransitionPropsProp,
...other
} = props;

Expand Down Expand Up @@ -188,12 +186,9 @@ const Accordion = React.forwardRef(function Accordion(inProps, ref) {

const classes = useUtilityClasses(ownerState);

const backwardCompatibleSlots = { transition: TransitionComponentProp, ...slots };
const backwardCompatibleSlotProps = { transition: TransitionPropsProp, ...slotProps };

const externalForwardedProps = {
slots: backwardCompatibleSlots,
slotProps: backwardCompatibleSlotProps,
slots,
slotProps,
};

const [RootSlot, rootProps] = useSlot('root', {
Expand Down Expand Up @@ -331,18 +326,6 @@ Accordion.propTypes /* remove-proptypes */ = {
PropTypes.func,
PropTypes.object,
]),
/**
* The component used for the transition.
* [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
* @deprecated Use `slots.transition` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*/
TransitionComponent: PropTypes.elementType,
/**
* Props applied to the transition element.
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
* @deprecated Use `slotProps.transition` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*/
TransitionProps: PropTypes.object,
};

export default Accordion;
16 changes: 8 additions & 8 deletions packages/mui-material/src/Accordion/Accordion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('<Accordion />', () => {

it('should be controlled', () => {
const { container, setProps } = render(
<Accordion expanded TransitionComponent={NoTransition}>
<Accordion expanded slots={{ transition: NoTransition }}>
{minimalChildren}
</Accordion>,
);
Expand All @@ -94,7 +94,7 @@ describe('<Accordion />', () => {
const handleChange = spy();

render(
<Accordion onChange={handleChange} TransitionComponent={NoTransition}>
<Accordion onChange={handleChange} slots={{ transition: NoTransition }}>
{minimalChildren}
</Accordion>,
);
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('<Accordion />', () => {
expect(container.firstChild).to.have.class(classes.disabled);
});

it('should handle the TransitionComponent prop', () => {
it('should handle the slots.transition prop', () => {
function NoTransitionCollapse(props) {
return props.in ? <div>{props.children}</div> : null;
}
Expand All @@ -147,7 +147,7 @@ describe('<Accordion />', () => {
return <div>Hello</div>;
}
const { setProps } = render(
<Accordion expanded TransitionComponent={NoTransitionCollapse}>
<Accordion expanded slots={{ transition: NoTransitionCollapse }}>
<AccordionSummary />
<CustomContent />
</Accordion>,
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('<Accordion />', () => {

it('should warn when switching from controlled to uncontrolled', () => {
const { setProps } = render(
<Accordion expanded TransitionComponent={NoTransition}>
<Accordion expanded slots={{ transition: NoTransition }}>
{minimalChildren}
</Accordion>,
);
Expand All @@ -233,18 +233,18 @@ describe('<Accordion />', () => {

it('should warn when switching between uncontrolled to controlled', () => {
const { setProps } = render(
<Accordion TransitionComponent={NoTransition}>{minimalChildren}</Accordion>,
<Accordion slots={{ transition: NoTransition }}>{minimalChildren}</Accordion>,
);

expect(() => setProps({ expanded: true })).toErrorDev(
'MUI: A component is changing the uncontrolled expanded state of Accordion to be controlled.',
);
});

describe('prop: TransitionProps', () => {
describe('slotProps.transition', () => {
it('should apply properties to the Transition component', () => {
render(
<Accordion TransitionProps={{ 'data-testid': 'transition-testid' }}>
<Accordion slotProps={{ transition: { 'data-testid': 'transition-testid' } }}>
{minimalChildren}
</Accordion>,
);
Expand Down
Loading