Skip to content
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

Select does not display options initially when filterOption prop is specified #4504

Open
alinjie opened this issue Mar 19, 2021 · 5 comments

Comments

@alinjie
Copy link

alinjie commented Mar 19, 2021

Version 3.2.0 seemed to introduce an issue where options are not displayed when there is not input value and the filterOption prop is present. This worked fine in version 3.1.1

Working example
https://codesandbox.io/s/311-working-301yt

Nonworking example
https://codesandbox.io/s/320-not-working-ibgc7?file=/example.js:389-445

To reproduce, click the select in both examples and notice that options are only displayed in the 3.1.1 example. Options are however rendered when there is an input present in the 3.2.0 example.

Thanks!

@alinjie alinjie changed the title Select does not show opi Select does not show option initially when filterOption prop is specified Mar 19, 2021
@alinjie alinjie changed the title Select does not show option initially when filterOption prop is specified Select does not display options initially when filterOption prop is specified Mar 19, 2021
@h3rmanj
Copy link

h3rmanj commented Mar 19, 2021

I've also noticed this, as I used the workaround for limiting displayed options in large sets, which no longer works.
#126 (comment)

@alinjie
Copy link
Author

alinjie commented Mar 19, 2021

Interesting side note;
Setting the limit variable to colourOptions.length + 1 displays one option in the menu, colourOptions.length + 2 displays two and so on.

@h3rmanj
Copy link

h3rmanj commented Mar 19, 2021

After some debugging, I've found that it's this change that broke it. #3990
Specifically the equality check on selectValue. I'll try to throw in a PR.
Edit: Nevermind, the code has changed too much from this. The reason it doesn't work anymore is bc buildCategorizedOptions is called multiple times per render, meaning filterOptions get called 2-5 times per option. Maybe it should be memoized?

@ebonow
Copy link
Collaborator

ebonow commented Mar 19, 2021

Greetings,

Thanks for the find @h3rmanj !

Some next steps I think to put around this:

  1. Memo the buildCategorizedOptions is a good first step
  2. There should be a feature request added so that maxOptions can be specified in the filterOptions and/or the filterOptions function exposes an index to allow the user this ability.

Thoughts?

@h3rmanj
Copy link

h3rmanj commented Mar 22, 2021

I agree with 1, and have made a PR in #4514.
As for 2, I still think using filterOption to limit the amount of rendered options is somewhat clunky, and tried to just directly add a prop that limits the rendered options in #4515.

I did them in seperate PRs so they could be addressed individually. Either would solve this issue, but both would be nice to have.

Edit: Opened a feature request as well in #4516

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

No branches or pull requests

3 participants