Skip to content

Commit 5c0196b

Browse files
willwill96EsoterikStare
authored andcommitted
[Autocomplete] Update docs for defaultValue prop (mui#19431)
1 parent 0895d6f commit 5c0196b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/pages/api/autocomplete.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
3535
| <span class="prop-name">closeIcon</span> | <span class="prop-type">node</span> | <span class="prop-default">&lt;CloseIcon fontSize="small" /></span> | The icon to display in place of the default close icon. |
3636
| <span class="prop-name">closeText</span> | <span class="prop-type">string</span> | <span class="prop-default">'Close'</span> | Override the default text for the *close popup* icon button.<br>For localization purposes, you can use the provided [translations](/guides/localization/). |
3737
| <span class="prop-name">debug</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the popup will ignore the blur event if the input if filled. You can inspect the popup markup with your browser tools. Consider this option when you need to customize the component. |
38-
| <span class="prop-name">defaultValue</span> | <span class="prop-type">any<br>&#124;&nbsp;array</span> | | The default input value. Use when the component is not controlled. |
38+
| <span class="prop-name">defaultValue</span> | <span class="prop-type">any<br>&#124;&nbsp;array</span> | <span class="prop-default">props.multiple ? [] : null</span> | The default input value. Use when the component is not controlled. |
3939
| <span class="prop-name">disableClearable</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the input can't be cleared. |
4040
| <span class="prop-name">disableCloseOnSelect</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the popup won't close when a value is selected. |
4141
| <span class="prop-name">disabled</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the input will be disabled. |

packages/material-ui-lab/src/Autocomplete/Autocomplete.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
247247
closeIcon = <CloseIcon fontSize="small" />,
248248
closeText = 'Close',
249249
debug = false,
250-
defaultValue,
250+
defaultValue = props.multiple ? [] : null,
251251
disableClearable = false,
252252
disableCloseOnSelect = false,
253253
disabled = false,

packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default function useAutocomplete(props) {
8585
blurOnSelect = false,
8686
clearOnEscape = false,
8787
debug = false,
88-
defaultValue,
88+
defaultValue = props.multiple ? [] : null,
8989
disableClearable = false,
9090
disableCloseOnSelect = false,
9191
disableListWrap = false,
@@ -193,7 +193,7 @@ export default function useAutocomplete(props) {
193193

194194
const [value, setValue] = useControlled({
195195
controlled: valueProp,
196-
default: defaultValue || (multiple ? [] : null),
196+
default: defaultValue,
197197
name: componentName,
198198
});
199199

0 commit comments

Comments
 (0)