admin管理员组文章数量:1192939
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 Chip
s
<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 Chip
s when an item is selected or entered.
Thanks
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 Chip
s
<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 Chip
s when an item is selected or entered.
Thanks
Share Improve this question asked Nov 10, 2019 at 17:47 ArthurArthur 3,9425 gold badges30 silver badges49 bronze badges1 Answer
Reset to default 29This 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
}
}}
本文标签: javascriptMaterial Autocomplete does not work with InputPropsStack Overflow
版权声明:本文标题:javascript - Material Autocomplete does not work with InputProps - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738430390a2086365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论