diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.js b/packages/mui-material/src/Autocomplete/Autocomplete.js index 5691eb04673be5..72d357182ee599 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.js @@ -588,23 +588,29 @@ const Autocomplete = React.forwardRef(function Autocomplete(inProps, ref) { ...getItemProps(params), }); - if (renderTags && multiple && value.length > 0) { - startAdornment = renderTags(value, getCustomizedItemProps, ownerState); + if (multiple) { + if (value.length > 0) { + if (renderTags) { + startAdornment = renderTags(value, getCustomizedItemProps, ownerState); + } else if (renderValue) { + startAdornment = renderValue(value, getCustomizedItemProps, ownerState); + } else { + startAdornment = value.map((option, index) => { + const { key, ...customItemProps } = getCustomizedItemProps({ index }); + return ( + + ); + }); + } + } } else if (renderValue && value) { startAdornment = renderValue(value, getCustomizedItemProps, ownerState); - } else if (multiple && value.length > 0) { - startAdornment = value.map((option, index) => { - const { key, ...customItemProps } = getCustomizedItemProps({ index }); - return ( - - ); - }); } if (limitTags > -1 && Array.isArray(startAdornment)) { diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.test.js b/packages/mui-material/src/Autocomplete/Autocomplete.test.js index 4184039129eb83..62476283c05950 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.test.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.test.js @@ -3598,4 +3598,29 @@ describe('', () => { expect(textbox).toHaveFocus(); }); }); + + it('should not shrink the input label when value is an empty array in multiple mode using renderValue', () => { + const { getByTestId } = render( + + values.map((option, index) => { + const { key, ...itemProps } = getItemProps({ index }); + return ; + }) + } + renderInput={(params) => ( + + )} + />, + ); + + expect(getByTestId('label')).to.have.attribute('data-shrink', 'false'); + }); });