Using start adornments on multiple select autocompletes makes the chips stop rendering.
If you try to have a multiple select autocomplete with adornment the chips won't render anymore
To have the ability to use adornments without breaking the autocomplete
Add InputProps.startAdornment to the params that you get on the render function, pass it onto the textField and see what happens.
https://codesandbox.io/s/bug-on-addornments-b22gr
I tried this approach with non-multiple autocompletes and it worked just fine
I believe I found a solution: CodeSandbox
The important code is below. Basically, you need to make sure you
params to the TextField with {...params}InputProps to the TextField. This prop should be an object where you first spread all the props from params.InputProps.InputProps should also have a property called startAdornment. This is the tricky part: make the startAdornment a React Fragment containing whatever InputAdornments you want. Then, pass in the startAdornment from the params with {params.InputProps.startAdornment} as a child.<Autocomplete
multiple
options={top100Films}
getOptionLabel={option => option.title}
renderInput={params => {
return (
<TextField
{...params}
variant="standard"
label="Multiple values"
placeholder="Favorites"
fullWidth
InputProps={{
...params.InputProps,
startAdornment: (
<>
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
{params.InputProps.startAdornment}
</>
)
}}
/>
);
}}
/>
Explanation: I think the Chips are themselves InputAdornments and they are added via the startAdornment. So in order to not wipe those out when we pass our own startAdornment, you have to explicitly display the params.InputProps.startAdornment
Most helpful comment
I believe I found a solution: CodeSandbox
The important code is below. Basically, you need to make sure you
paramsto theTextFieldwith{...params}InputPropsto theTextField. This prop should be an object where you first spread all the props fromparams.InputProps.InputPropsshould also have a property calledstartAdornment. This is the tricky part: make thestartAdornmenta React Fragment containing whateverInputAdornments you want. Then, pass in thestartAdornmentfrom theparamswith{params.InputProps.startAdornment}as a child.Explanation: I think the
Chips are themselvesInputAdornments and they are added via thestartAdornment. So in order to not wipe those out when we pass our ownstartAdornment, you have to explicitly display theparams.InputProps.startAdornment