Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

Limit items show in the menu #374

Open
jmarcosvillar opened this issue Jan 9, 2019 · 2 comments
Open

Limit items show in the menu #374

jmarcosvillar opened this issue Jan 9, 2019 · 2 comments

Comments

@jmarcosvillar
Copy link

Actually, I am using a +900 list, but I only want to show 10 records on the menu.
But when I try to scroll down with a modified children list on renderMenu, it crash.

@jmarcosvillar jmarcosvillar changed the title Autocomplete items limit? Limit items show in the menu Jan 9, 2019
@ilya-section4
Copy link

+1 would like to see this feature

@FedeG
Copy link

FedeG commented Jul 16, 2019

@jmarcosvillar @ilya-section4 work-arround/solution:

class LimitedAutocomplete extends Autocomplete {
  getFilteredItems(props) {
    let items = props.items

    if (props.shouldItemRender) {
      items = items.filter((item) => (
        props.shouldItemRender(item, props.value)
      ))
    }

    if (props.sortItems) {
      items.sort((a, b) => (
        props.sortItems(a, b, props.value)
      ))
    }

    return items.slice(0, props.limitItemsLength);
  }
}

Or

class LimitedAutocomplete extends Autocomplete {
  getFilteredItems(props) {
    const items = Autocomplete.prototype.getFilteredItems.call(this, props);
    return items.slice(0, props.limitItemsLength);
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants