-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Limiting number of options displayed in dropdown #126
Comments
@super-cache-money how would they be sorted? |
If you are only concerned about the display this css may help you out:
I know this isn't pretty at all but as long as this doesn't impact your performance too hard it may be a quick-and-dirty workaround until this is implemented. |
I'm in a similar situation. I've got 4000 options and would like to either limit the number of options displayed or start filtering only if the input is longer than 3 characters. Do you know if there's a way to do this? |
I'm in a similar case where I have just 6 options and I'd like to display all 6 options at once instead of requiring the user to scroll down just to see 1 more item. Is CSS still the best way to do this? |
+1 |
2 similar comments
+1 |
+1 |
Oh, I just hit this as well. To fit visually, I need to limit it to the dropdown just showing 2-3 options and scroll the rest. The above CSS will not display the options though. It looks like setting |
…ction results count. It shows the first `filterMaxResuls` items. FIX JedWatson#126
…ction results count. It shows the first `filterMaxResuls` items. FIX JedWatson#126
I created a PR which should provide |
…ction results count. It shows the first `filterMaxResults` items. FIX JedWatson#126
…ction results count. It shows the first `filterMaxResults` items. FIX JedWatson#126
+1 |
1 similar comment
+1 |
Any updates on this? |
+1 |
You can use the props |
In the meantime I am using in my code this (awful) workaround:
Where 10 is my limit
In this way you will still be able to search inside the list but you will display just the first 10 elements of the list UPDATE: |
Why not just go with Example with limit: <AsyncSelect
loadOptions={(inputValue, callback) => {
callback(selectOptions.slice(0, 50))
}}
defaultOptions={true}
value={value}
onChange={(val) => this.onValueChanged(val)}
/> Example with limit and simple serach: <AsyncSelect
loadOptions={(inputValue, callback) => {
callback(selectOptions.filter(x => x.label.toLowerCase().includes(inputValue.toLowerCase())).slice(0, 50))
}}
defaultOptions={true}
value={value}
onChange={(val) => this.onValueChanged(val)}
/> |
Quick temp solution: const resultLimit = 10
let i = 0
return <Select filterOption={({label}, query) => label.indexOf(query) >= 0 && i++ < resultLimit} onInputChange={() => { i = 0 }} /> |
Solution provided by @vitexikora worked for me, but I'd like to point out that 'label' will be the visual option for the user, so I'd rather use value, which should be sanitized and/or normalized. const resultLimit = 10
let i = 0
return <Select filterOption={({value}, query) => value.indexOf(query.toLowerCase()) >= 0 && i++ < resultLimit} onInputChange={() => { i = 0 }} /> |
@vitexikora that solution works great. Thanks! |
@vitexikora solution worked for me also! Im dealing with 50k options, and with this solution I can search between that all records. The only issue is that it only displays the 10 first values, I will try to make it async using |
Version 1 of react-select is no longer supported. In the best interest of the community we've decided to spend the time we have available on the latest version. We apologise for any inconvenience. Please see: |
In case anyone is looking for dropdown menu with a limited number of options and scroll; use the <Select
maxMenuHeight={175}
options={options}
value={value}
/> |
For example, how would one only show the 5 closest matches to input text in the dropdown, despite having 1000 options which are searchable.
The text was updated successfully, but these errors were encountered: