Currently, the PopperComponent
width is always set to anchorEl.clientWidth
(see https://github.com/mui-org/material-ui/blob/master/packages/material-ui-lab/src/Autocomplete/Autocomplete.js#L440-L442). I would like to be able to customize that so the dropdown can be a different width. It would probably make sense to also expose the placement
of the popper. I'm not sure if it makes more sense to just expose PopperProps
-- I saw in this issue that you're not the biggest fan of that approach: https://github.com/mui-org/material-ui/issues/18885#issuecomment-566494202
The search box on the material-ui docs is an example of where the dropdown is a different width than
I have content in my dropdown that is wider than the search box and it currently has an annoying wrap. Also, having the textbox width expand with css like in the material-ui documentation can result in a mis-aligned and too-small popper.
You can provide a custom PopperComponent
prop to change the positioning logic.
This worked for me:
const PopperMy = function (props) {
return (<Popper {...props} style={{ width: 250 }} placement='bottom-start' />)
}
then
<Autocomplete PopperComponent={PopperMy}>
Most helpful comment
This worked for me:
then