【发布时间】:2021-11-23 21:49:17
【问题描述】:
当使用variant='filled' 设置材质ui <Autocomplete /> 时,endInputAdornments 不会以自动完成为中心。
Codesandbox 有两种变体供参考
<Autocomplete
disablePortal
id="combo-box-demo"
options={top100Films}
sx={{ width: 300, mt: 2 }}
renderInput={(params) => (
<TextField
{...params}
label="Movie"
variant="filled" //With filled it does not center anymore
InputProps={{
...params.InputProps,
endAdornment: (
<React.Fragment>
{params.InputProps.endAdornment}
<IconButton
color="primary"
aria-label="upload picture"
component="span"
>
<PhotoCamera />
</IconButton>
</React.Fragment>
)
}}
/>
我找到了github issue,他们在内部为 inputProps 修复了它,但我似乎无法找到一种方法来对我自己的装饰元素做同样的事情。
似乎相关的唯一道具是 popupIcon,但我仍然想要该默认功能。我只是希望能够在 endInputAdornments 中添加更多 IconButtons
【问题讨论】:
标签: reactjs material-ui