Skip to content
Merged
185 changes: 185 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 @@ -231,6 +231,191 @@ The `autoFocus` prop in `MenuList` does not set `tabindex="0"` on the `List` com

APIs that were deprecated earlier have been removed in v9.

#### Autocomplete deprecated props removed

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

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

The following deprecated props have been removed from the `Autocomplete` component:

- `ChipProps` → use `slotProps.chip`
- `componentsProps` → use `slotProps`
- `ListboxComponent` → use `slots.listbox`
- `ListboxProps` → use `slotProps.listbox`
- `PaperComponent` → use `slots.paper`
- `PopperComponent` → use `slots.popper`
- `renderTags` → use `renderValue`

##### ChipProps prop

The deprecated `ChipProps` prop has been removed. Use `slotProps.chip` instead.

```diff
<Autocomplete
multiple
options={options}
- ChipProps={{ size: 'small' }}
+ slotProps={{ chip: { size: 'small' } }}
/>
```

##### componentsProps prop

The deprecated `componentsProps` prop has been removed. Use `slotProps` instead.

```diff
<Autocomplete
options={options}
renderInput={(params) => <TextField {...params} />}
- componentsProps={{
- clearIndicator: { size: 'large' },
- paper: { elevation: 2 },
- popper: { placement: 'bottom-end' },
- popupIndicator: { size: 'large' },
- }}
+ slotProps={{
+ clearIndicator: { size: 'large' },
+ paper: { elevation: 2 },
+ popper: { placement: 'bottom-end' },
+ popupIndicator: { size: 'large' },
+ }}
/>
```

##### ListboxComponent and ListboxProps props

The deprecated `ListboxComponent` and `ListboxProps` props have been removed.

Use `slots.listbox` instead of `ListboxComponent`:

```diff
<Autocomplete
options={options}
renderInput={(params) => <TextField {...params} />}
- ListboxComponent={CustomListbox}
+ slots={{ listbox: CustomListbox }}
/>
```

Use `slotProps.listbox` instead of `ListboxProps`:

```diff
<Autocomplete
options={options}
renderInput={(params) => <TextField {...params} />}
- ListboxProps={{ style: { maxHeight: 200 } }}
+ slotProps={{ listbox: { style: { maxHeight: 200 } } }}
/>
```

If you were passing a `ref` via `ListboxProps`, move it to `slotProps.listbox.ref`:

```diff
<Autocomplete
options={options}
renderInput={(params) => <TextField {...params} />}
- ListboxProps={{ ref }}
+ slotProps={{ listbox: { ref } }}
/>
```

##### PaperComponent and PopperComponent props

The deprecated `PaperComponent` and `PopperComponent` props have been removed. Use `slots.paper` and `slots.popper` instead.

```diff
<Autocomplete
options={options}
renderInput={(params) => <TextField {...params} />}
- PaperComponent={CustomPaper}
- PopperComponent={CustomPopper}
+ slots={{
+ paper: CustomPaper,
+ popper: CustomPopper,
+ }}
/>
```

If you were providing an inline component:

```diff
<Autocomplete
options={options}
renderInput={(params) => <TextField {...params} />}
- PopperComponent={(props) => {
- const { disablePortal, anchorEl, open, ...other } = props;
- return <Box {...other} />;
- }}
+ slots={{
+ popper: (props) => {
+ const { disablePortal, anchorEl, open, ...other } = props;
+ return <Box {...other} />;
+ },
+ }}
/>
```

##### renderTags prop

The deprecated `renderTags` prop has been removed. Use `renderValue` instead.

```diff
<Autocomplete
multiple
options={options}
- renderTags={(value, getTagProps, ownerState) =>
- value.map((option, index) => (
- <Chip label={option.label} {...getTagProps({ index })} />
- ))
- }
+ renderValue={(value, getItemProps, ownerState) =>
+ value.map((option, index) => (
+ <Chip label={option.label} {...getItemProps({ index })} />
+ ))
+ }
/>
```

---

#### useAutocomplete deprecated fields removed

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

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

The following deprecated members have been removed from the `useAutocomplete` hook return value:

- `getTagProps` → use `getItemProps`
- `focusedTag` → use `focusedItem`

##### getTagProps

```diff
const {
- getTagProps,
+ getItemProps,
} = useAutocomplete(props);

// ...
-<Chip {...getTagProps({ index })} />
+<Chip {...getItemProps({ index })} />
```

##### focusedTag

```diff
const {
- focusedTag,
+ focusedItem,
} = useAutocomplete(props);
```

#### TextField deprecated props removed

Use the [text-field-props codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#text-field-props) below to migrate the code as described in the following section:
Expand Down
45 changes: 0 additions & 45 deletions docs/pages/material-ui/api/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,12 @@
},
"default": "false"
},
"ChipProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.chip</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."
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"clearIcon": { "type": { "name": "node" }, "default": "<ClearIcon fontSize=\"small\" />" },
"clearOnBlur": { "type": { "name": "bool" }, "default": "!props.freeSolo" },
"clearOnEscape": { "type": { "name": "bool" }, "default": "false" },
"clearText": { "type": { "name": "string" }, "default": "'Clear'" },
"closeText": { "type": { "name": "string" }, "default": "'Close'" },
"componentsProps": {
"type": {
"name": "shape",
"description": "{ clearIndicator?: object, paper?: object, popper?: object, popupIndicator?: object }"
},
"deprecated": true,
"deprecationInfo": "Use the <code>slotProps</code> prop instead. This prop will be removed in a future major release. See <a href=\"https://mui.com/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
},
"defaultValue": {
"type": { "name": "custom", "description": "any" },
"default": "props.multiple ? [] : null"
Expand Down Expand Up @@ -97,17 +84,6 @@
}
},
"limitTags": { "type": { "name": "custom", "description": "integer" }, "default": "-1" },
"ListboxComponent": {
"type": { "name": "elementType" },
"default": "'ul'",
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.listbox.component</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."
},
"ListboxProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.listbox</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."
},
"loading": { "type": { "name": "bool" }, "default": "false" },
"loadingText": { "type": { "name": "node" }, "default": "'Loading…'" },
"multiple": { "type": { "name": "bool" }, "default": "false" },
Expand Down Expand Up @@ -150,18 +126,6 @@
"open": { "type": { "name": "bool" } },
"openOnFocus": { "type": { "name": "bool" }, "default": "false" },
"openText": { "type": { "name": "string" }, "default": "'Open'" },
"PaperComponent": {
"type": { "name": "elementType" },
"default": "Paper",
"deprecated": true,
"deprecationInfo": "Use <code>slots.paper</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."
},
"PopperComponent": {
"type": { "name": "elementType" },
"default": "Popper",
"deprecated": true,
"deprecationInfo": "Use <code>slots.popper</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."
},
"popupIcon": { "type": { "name": "node" }, "default": "<ArrowDropDownIcon />" },
"readOnly": { "type": { "name": "bool" }, "default": "false" },
"renderGroup": {
Expand All @@ -178,15 +142,6 @@
"describedArgs": ["props", "option", "state", "ownerState"]
}
},
"renderTags": {
"type": { "name": "func" },
"deprecated": true,
"deprecationInfo": "Use <code>renderValue</code> prop instead",
"signature": {
"type": "function(value: Array<Value>, getTagProps: function, ownerState: object) => ReactNode",
"describedArgs": ["value", "getTagProps", "ownerState"]
}
},
"renderValue": {
"type": { "name": "func" },
"signature": {
Expand Down
22 changes: 0 additions & 22 deletions docs/translations/api-docs/autocomplete/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"blurOnSelect": {
"description": "<p>Control if the input should be blurred when an option is selected:</p>\n<ul>\n<li><code>false</code> the input is not blurred.</li>\n<li><code>true</code> the input is always blurred.</li>\n<li><code>touch</code> the input is blurred after a touch event.</li>\n<li><code>mouse</code> the input is blurred after a mouse event.</li>\n</ul>\n"
},
"ChipProps": {
"description": "Props applied to the <a href=\"https://mui.com/material-ui/api/chip/\"><code>Chip</code></a> element."
},
"classes": { "description": "Override or extend the styles applied to the component." },
"clearIcon": { "description": "The icon to display in place of the default clear icon." },
"clearOnBlur": {
Expand All @@ -30,7 +27,6 @@
"closeText": {
"description": "Override the default text for the <em>close popup</em> icon button.<br>For localization purposes, you can use the provided <a href=\"https://mui.com/material-ui/guides/localization/\">translations</a>."
},
"componentsProps": { "description": "The props used for each slot inside." },
"defaultValue": {
"description": "The default value. Use when the component is not controlled."
},
Expand Down Expand Up @@ -117,8 +113,6 @@
"limitTags": {
"description": "The maximum number of tags that will be visible when not focused. Set <code>-1</code> to disable the limit."
},
"ListboxComponent": { "description": "The component used to render the listbox." },
"ListboxProps": { "description": "Props applied to the Listbox element." },
"loading": {
"description": "If <code>true</code>, the component is in a loading state. This shows the <code>loadingText</code> in place of suggestions (only if there are no suggestions to show, for example <code>options</code> are empty)."
},
Expand Down Expand Up @@ -186,8 +180,6 @@
"description": "Override the default text for the <em>open popup</em> icon button.<br>For localization purposes, you can use the provided <a href=\"https://mui.com/material-ui/guides/localization/\">translations</a>."
},
"options": { "description": "A list of options that will be shown in the Autocomplete." },
"PaperComponent": { "description": "The component used to render the body of the popup." },
"PopperComponent": { "description": "The component used to position the popup." },
"popupIcon": { "description": "The icon to display in place of the default popup icon." },
"readOnly": {
"description": "If <code>true</code>, the component becomes readonly. It is also supported for multiple tags where the tag cannot be deleted."
Expand All @@ -211,20 +203,6 @@
}
}
},
"renderTags": {
"description": "Render the selected value when doing multiple selections.",
"typeDescriptions": {
"value": {
"name": "value",
"description": "The <code>value</code> provided to the component."
},
"getTagProps": { "name": "getTagProps", "description": "A tag props getter." },
"ownerState": {
"name": "ownerState",
"description": "The state of the Autocomplete component."
}
}
},
"renderValue": {
"description": "Renders the selected value(s) as rich content in the input for both single and multiple selections.",
"typeDescriptions": {
Expand Down
Loading
Loading