reactjs / react-autocomplete

WAI-ARIA compliant React autocomplete (combobox) component
MIT License
2.17k stars 532 forks source link

Set max size of the visible items #320

Closed stanyq4 closed 6 years ago

stanyq4 commented 6 years ago

Is there an out of the box solution to set the max number of visible items in the drop-down?

Would be great to in case the item list is getting too big.

CMTegner commented 6 years ago

If you want a visual limit you can set max-height on the dropdown menu via CSS. If you want to limit the number of items rendered I suggest filtering the list of items outside of Autocomplete instead of specifying the shouldItemRender prop.

miles-crighton commented 5 years ago

I found a little workaround to limit the children rendered in the menu using this prop:

renderMenu={ children => (
    <div className= "menu">
       {children.slice(0, maxMenuItems)}
    </div>
)}

Not sure if there are any issues with this.