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][Tooltip] deprecate *Component and *Props for v6 #42120

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
10 changes: 7 additions & 3 deletions docs/data/material/components/material-icons/SearchIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@ const DialogDetails = React.memo(function DialogDetails(props) {
<Tooltip
placement="right"
title={copied1 ? t('copied') : t('clickToCopy')}
TransitionProps={{
onExited: () => setCopied1(false),
slotProps={{
transition: {
onExited: () => setCopied1(false),
},
}}
>
<Title component="span" variant="inherit" onClick={handleClick(1)}>
Expand All @@ -304,7 +306,9 @@ const DialogDetails = React.memo(function DialogDetails(props) {
<Tooltip
placement="top"
title={copied2 ? t('copied') : t('clickToCopy')}
TransitionProps={{ onExited: () => setCopied2(false) }}
slotProps={{
transition: { onExited: () => setCopied2(false) },
}}
>
<Markdown
copyButtonHidden
Expand Down
22 changes: 12 additions & 10 deletions docs/data/material/components/tooltips/AnchorElTooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ export default function AnchorElTooltips() {
title="Add"
placement="top"
arrow
PopperProps={{
popperRef,
anchorEl: {
getBoundingClientRect: () => {
return new DOMRect(
positionRef.current.x,
areaRef.current.getBoundingClientRect().y,
0,
0,
);
slotProps={{
popper: {
popperRef,
anchorEl: {
getBoundingClientRect: () => {
return new DOMRect(
positionRef.current.x,
areaRef.current.getBoundingClientRect().y,
0,
0,
);
},
},
},
}}
Expand Down
22 changes: 12 additions & 10 deletions docs/data/material/components/tooltips/AnchorElTooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ export default function AnchorElTooltips() {
title="Add"
placement="top"
arrow
PopperProps={{
popperRef,
anchorEl: {
getBoundingClientRect: () => {
return new DOMRect(
positionRef.current.x,
areaRef.current!.getBoundingClientRect().y,
0,
0,
);
slotProps={{
popper: {
popperRef,
anchorEl: {
getBoundingClientRect: () => {
return new DOMRect(
positionRef.current.x,
areaRef.current!.getBoundingClientRect().y,
0,
0,
);
},
},
},
}}
Expand Down
15 changes: 12 additions & 3 deletions docs/data/material/components/tooltips/TransitionsTooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ export default function TransitionsTooltips() {
<Button>Grow</Button>
</Tooltip>
<Tooltip
TransitionComponent={Fade}
TransitionProps={{ timeout: 600 }}
title="Add"
slots={{
transition: Fade,
}}
slotProps={{
transition: { timeout: 600 },
}}
>
<Button>Fade</Button>
</Tooltip>
<Tooltip TransitionComponent={Zoom} title="Add">
<Tooltip
title="Add"
slots={{
transition: Zoom,
}}
>
<Button>Zoom</Button>
</Tooltip>
</div>
Expand Down
15 changes: 12 additions & 3 deletions docs/data/material/components/tooltips/TransitionsTooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ export default function TransitionsTooltips() {
<Button>Grow</Button>
</Tooltip>
<Tooltip
TransitionComponent={Fade}
TransitionProps={{ timeout: 600 }}
title="Add"
slots={{
transition: Fade,
}}
slotProps={{
transition: { timeout: 600 },
}}
>
<Button>Fade</Button>
</Tooltip>
<Tooltip TransitionComponent={Zoom} title="Add">
<Tooltip
title="Add"
slots={{
transition: Zoom,
}}
>
<Button>Zoom</Button>
</Tooltip>
</div>
Expand Down

This file was deleted.

8 changes: 5 additions & 3 deletions docs/data/material/components/tooltips/TriggersTooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ export default function TriggersTooltips() {
<ClickAwayListener onClickAway={handleTooltipClose}>
<div>
<Tooltip
PopperProps={{
disablePortal: true,
}}
onClose={handleTooltipClose}
open={open}
disableFocusListener
disableHoverListener
disableTouchListener
title="Add"
slotProps={{
popper: {
disablePortal: true,
},
}}
>
<Button onClick={handleTooltipOpen}>Click</Button>
</Tooltip>
Expand Down
8 changes: 5 additions & 3 deletions docs/data/material/components/tooltips/TriggersTooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ export default function TriggersTooltips() {
<ClickAwayListener onClickAway={handleTooltipClose}>
<div>
<Tooltip
PopperProps={{
disablePortal: true,
}}
onClose={handleTooltipClose}
open={open}
disableFocusListener
disableHoverListener
disableTouchListener
title="Add"
slotProps={{
popper: {
disablePortal: true,
},
}}
>
<Button onClick={handleTooltipOpen}>Click</Button>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1133,3 +1133,41 @@ The SpeedDial's `TransitionProps` was deprecated in favor of `slotProps.transiti
+ slotProps={{ transition: { unmountOnExit: true } }}
/>
```

## Tooltip

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

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

### \*Component props

All of the Tooltip's slot (`*Component`) props were deprecated in favor of equivalent `slots` entries:

```diff
<Tooltip
- PopperComponent={CustomPopperComponent}
- TransitionComponent={CustomTransitionComponent}
+ slots={{
+ popper: CustomPopperComponent,
+ transition: CustomTransitionComponent,
+ }}
/>
```

### \*Props props

All of the Tooltip's slot props (`*Props`) props were deprecated in favor of equivalent `slotProps` entries:

```diff
<Tooltip
- PopperProps={CustomPopperProps}
- TransitionProps={CustomTransitionProps}
+ slotProps={{
+ popper: CustomPopperProps,
+ transition: CustomTransitionProps,
+ }}
/>
```
24 changes: 20 additions & 4 deletions docs/pages/material-ui/api/tooltip.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@
},
"default": "'bottom'"
},
"PopperComponent": { "type": { "name": "elementType" }, "default": "Popper" },
"PopperProps": { "type": { "name": "object" }, "default": "{}" },
"PopperComponent": {
"type": { "name": "elementType" },
"deprecated": true,
"deprecationInfo": "Use <code>slots.popper</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"PopperProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.popper</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"slotProps": {
"type": {
"name": "shape",
Expand All @@ -75,8 +83,16 @@
"additionalInfo": { "sx": true }
},
"title": { "type": { "name": "node" } },
"TransitionComponent": { "type": { "name": "elementType" }, "default": "Grow" },
"TransitionProps": { "type": { "name": "object" } }
"TransitionComponent": {
"type": { "name": "elementType" },
"deprecated": true,
"deprecationInfo": "Use <code>slots.transition</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"TransitionProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.transition</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
}
},
"name": "Tooltip",
"imports": [
Expand Down
42 changes: 42 additions & 0 deletions packages/mui-codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,48 @@ CSS transforms:
npx @mui/codemod@latest deprecations/toggle-button-group-classes <path>
```

#### `tooltip-props`

```diff
<Tooltip
- PopperComponent={CustomPopperComponent}
- TransitionComponent={CustomTransitionComponent}
- PopperProps={CustomPopperProps}
- TransitionProps={CustomTransitionProps}
+ slots={{
+ popper: CustomPopperComponent,
+ transition: CustomTransitionComponent,
+ }}
+ slotProps={{
+ popper: CustomPopperProps,
+ transition: CustomTransitionProps,
+ }}
/>
```

```diff
MuiTooltip: {
defaultProps: {
- PopperComponent: CustomPopperComponent,
- TransitionComponent: CustomTransitionComponent,
- PopperProps: CustomPopperProps,
- TransitionProps: CustomTransitionProps,
+ slots: {
+ popper: CustomPopperComponent,
+ transition: CustomTransitionComponent,
+ },
+ slotProps: {
+ popper: CustomPopperProps,
+ transition: CustomTransitionProps,
+ },
},
},
```

```bash
npx @mui/codemod@next deprecations/tooltip-props <path>
```

#### `step-label-props`

```diff
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-codemod/src/deprecations/all/deprecations-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import transformStepLabelProps from '../step-label-props';
import transformBackdropProps from '../backdrop-props';
import transformStepConnectorClasses from '../step-connector-classes';
import transformSpeedDialProps from '../speed-dial-props';
import transformTooltipProps from '../tooltip-props';

/**
* @param {import('jscodeshift').FileInfo} file
Expand All @@ -34,6 +35,7 @@ export default function deprecationsAll(file, api, options) {
file.source = transformBackdropProps(file, api, options);
file.source = transformStepConnectorClasses(file, api, options);
file.source = transformSpeedDialProps(file, api, options);
file.source = transformTooltipProps(file, api, options);

return file.source;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './tooltip-props';
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Tooltip from '@mui/material/Tooltip';
import {Tooltip as MyTooltip} from '@mui/material';

<Tooltip
PopperComponent={CustomPopper}
TransitionComponent={CustomTransition}
PopperProps={{ disablePortal: true }}
TransitionProps={{ timeout: 200 }}
/>;

<Tooltip
PopperComponent={CustomPopper}
TransitionComponent={CustomTransition}
PopperProps={{ disablePortal: true }}
TransitionProps={{ timeout: 200 }}
slotProps={{
tooltip: { height: 20 }
}}
slots={{
tooltip: "div",
}}
/>;

<MyTooltip
PopperComponent={CustomPopper}
TransitionComponent={CustomTransition}
PopperProps={{ disablePortal: true }}
TransitionProps={{ timeout: 200 }}
/>;

<CustomTooltip
PopperComponent={CustomPopper}
TransitionComponent={CustomTransition}
PopperProps={{ disablePortal: true }}
TransitionProps={{ timeout: 200 }}
/>
Loading
Loading