【发布时间】:2022-01-25 06:01:54
【问题描述】:
我正在使用 MUI 自动完成功能,并在(从外部源)获取选项时向 Textfield 添加了一个 endAdornment 加载器,但是这会覆盖 MUI 的 clearIcon(可能是因为它也是一个 endAdornment)。如何确保保留默认的 clearIcon ?这是我的代码-
<Autocomplete
style={{ margin: 'auto' }}
options={itemOptions}
getOptionLabel={(option: Item) => option? option.name:''}
value={selectedItem}
inputValue={filterInput}
onInputChange={(e, v) => handleInputChange(v)}
onChange={(e, val) => {
if (val) {
handleItemSelect(val)
}
}}
renderInput={(params) => (
<TextField
{...params}
label="Items"
variant="outlined"
style={{ width: '300px' }}
InputProps={{
...params.InputProps,
endAdornment: (
<>
{loading ? <CircularProgress color="inherit" size={25} /> : null}
</>
),
}}
type="text"
/>
)}
/>
【问题讨论】:
标签: reactjs autocomplete material-ui