question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[AutoComplete] How to add scroll bar inside the render tags

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

How to add scroll bar inside the autocomplet to avoid too many lines as here:

image 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

image )

Expected Behavior 🤔

Add scrolling option image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
hadasmaimoncommented, Apr 27, 2020

@oliviertassinari the problem was: when wrapping renderTags content with div, this causes startAdornment.length to equal 1 instead of number of tags (because the tags are contained within the parent div) As a result, the limit tag does not appear, since more is not >0 (the result is negative)

My solution was: Wrap the tags only on OnOpen

Autocomplete code:

if (limitTags > -1 && Array.isArray(startAdornment)) {
    const more = startAdornment.length - limitTags;
    if (limitTags && !focused && more > 0) {
      startAdornment = startAdornment.splice(0, limitTags);
      startAdornment.push(
        <span className={classes.tag} key={startAdornment.length}>
          {getLimitTagsText(more)}
        </span>,
      );
    }
  }
0reactions
martin-trajanovskicommented, Nov 26, 2021

Has this issue been resolved? I’ve been facing the same problem but can’t seem to find a viable solution

@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 limitTags property but it’s not limiting the tags when input is focused… I am limiting the tags to 1 in my example but you can adjust to your needs.

   renderTags={(value, getTagProps) => {
        const numTags = value.length;
        const limitTags = 1;

        return (
          <>
            {value.slice(0, limitTags).map((option, index) => (
              <Chip
                {...getTagProps({ index })}
                key={index}
                label={option.name}
              />
            ))}

            {numTags > limitTags && ` +${numTags - limitTags}`}
          </>
        );
      }}
Read more comments on GitHub >

github_iconTop Results From Across the Web

[AutoComplete] How to add scroll bar inside the render tags
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >
I am trying to add a custom scrollbar component to my list of ...
A possible way to solve this problem is by styling the default tag used by MUI Autocomplete list component box.
Read more >
Add scroll event to jquery ui autocomplete - JSFiddle
1. <div class="ui-widget"> ; 2. <label for="tags">Tags: </label> ; 3. <input id="tags" /> ; 4. </div>.
Read more >
Autocomplete API - Material UI - MUI
Name Type Default options * array renderInput * func autoComplete bool false
Read more >
Scrollable jQuery UI Autocomplete
Scrollable jQuery UI Autocomplete Plugin for long items list. CSS max-height , overflow-y and padding-right can make scrollable list easy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found