I am trying to change the border of my TextField that is rendered through my Autocomplete, but when I add the InputProps prop, the Autocomplete no longer renders Chips
<Autocomplete
multiple
freeSolo
options={options}
renderTags={(value, { className, onDelete }) =>
value.map((option, index) => (
<Chip
key={index}
variant="outlined"
data-tag-index={index}
tabIndex={-1}
label={option}
className={className}
color="secondary"
onDelete={onDelete}
/>
))
}
renderInput={(params) => (
<TextField
{...params}
id={id}
className={textFieldStyles.searchField}
label={label}
value={value}
onChange={onChange}
variant="outlined"
//InputProps={{
// classes: {
// input: textFieldStyles.input,
// notchedOutline: textFieldStyles.notchedOutline
// }
//}}
InputLabelProps={{
classes: {
root: textFieldStyles.label
}
}}
/>
)}
/>
The above code works, and once I uncomment the InputProps line, the input no longer renders Chips when an item is selected or entered.
Thanks
This happens because the InputProps attribute is overriding the InputProps parameter of params, you have to merge InputProps property of params:
InputProps={{
...params.InputProps,
classes: {
input: textFieldStyles.input,
notchedOutline: textFieldStyles.notchedOutline
}
}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With