I'm using Material-UI Autcomplete component (Free solo version) and everything is working fine until I tried to change the color of the text (inside the TextField
).
My code looks like this:
const moreClasses = {
label: { style: { color: 'blue' } },
input: {
style: {
color: 'red',
borderBottom: `1px solid green`
}
}
};
//...
<Autocomplete
//... classic props as in the official Doc
renderInput={params => <TextField
{...params}
label={'label'}
InputLabelProps={moreClasses.label}
InputProps={moreClasses.input} />
/>
Expected behavior
When you start typing you can see the autcomplete and the text you type should have a red color.
Actual behavior
The text color is red but the autocomplete is not working anymore.
I created this live running example to illustrate the problem with 3 components:
The Text Field only (works)
The Autocomplete without changing the color using
InputProps
(works)The Autocomplete with changing the color using
InputProps
(does not work)
Note
By setting InputLabelProps
the autocomplete continue working and the color of the label is changed (to blue in the example I shared)! So I can't figure it out why it's not working when setting InputProps
.
Any feedback about this issue ?