-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AutoComplete] How to add scroll bar inside the render tags #20782
Comments
👋 Thanks for using Material-UI! We use GitHub issues exclusively as a bug and feature requests tracker, however, For support, please check out https://material-ui.com/getting-started/support/. Thanks! If you have a question on StackOverflow, you are welcome to link to it here, it might help others. |
@oliviertassinari the problem was: My solution was: Autocomplete code:
|
related to: #19137 |
use condition on the renderTags to make it scrollable onFocus. Here is an Example |
Has this issue been resolved? I've been facing the same problem but can't seem to find a viable solution |
Can you please send over the complete code for the |
@Nishant-Pall you probably need something like this if you want to limit the tags all the time not only when it's not focused because in the official documentation there is an example with
|
Here is how we got it working. style: { height: 'auto', maxHeight: '500px', overflow: 'auto' },
|
This worked for me: <Autocomplete
renderTags={(values, getTagProps) => (
<Box sx={{ maxHeight: theme => theme.spacing(8), overflowY: 'auto' }}>
{values.map((value, index) => (
<Chip
{...getTagProps({ index })}
key={index}
label={renderOption(value)}
/>
))}
</Box>
)}
/> Basically just add a Note that my maxHeight is a value I calculate from my theme. You can add any value you think fits well your project. |
Based on the source code here: material-ui/packages/mui-material/src/Autocomplete/Autocomplete.js Lines 537 to 548 in 450c4f6
Made a very slight change to your code above and it works great! renderTags={(values, getTagProps, owner) => (
<Box sx={{ maxHeight: "300px", overflowY: 'auto' }}>
{values.map((value, index) => (
<Chip
label={owner.getOptionLabel(value)}
size={owner.size}
{...getTagProps({ index })}
{...owner.ChipProps}
/>
))}
</Box>
)} I also had to add some logic to stop the popup Icon from appearing or else the scroll box appeared next to the popup icon in a weird way. |
I am facing the same issue with the Autocomplete component when using it in multiple mode. When the number of selected chips exceeds the maximum height, the chips are not displayed correctly, and the component does not become scrollable as expected. I have tried implementing the solutions mentioned in previous issues, including setting the ListboxProps with a maxHeight and adjusting the PaperComponent height, but none of these solutions have resolved the issue. if any one have solution pls let me know |
|
Current Behavior 😯
How to add scroll bar inside the autocomplet to avoid too many lines as here:
That question was posted in stack-overflow but had no answers
https://stackoverflow.com/questions/59917803/how-to-reduce-the-height-of-autocomplete-component-of-material-ui
(when I added maxWidth and overflow auto it broke the
limit tag
and broke the location of the search icon
)
Expected Behavior 🤔
Add scrolling option
The text was updated successfully, but these errors were encountered: