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.

Select does not display options initially when filterOption prop is specified

See original GitHub issue

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!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
ebonowcommented, 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?

1reaction
h3rmanjcommented, Mar 19, 2021

After some debugging, I’ve found that it’s this change that broke it. https://github.com/JedWatson/react-select/pull/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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-select sometimes doesn't display the options in the ...
I'm using "react-select": "^3.0.4", and had to add filterOption={false} prop.
Read more >
Select documentation for React | Mobiscroll
The Mobiscroll Select component has a data option (or data prop), that is used to define the selection options. The data option receives...
Read more >
Advanced - React Select
React-Select exports a createFilter function that returns a filterOption method. By using this, users can pick and choose bits of the filtration logic...
Read more >
Select - Ant Design
A dropdown menu for displaying choices - an elegant alternative to the native ... Specify the prop name of Option which will be...
Read more >
Apply a filter to view select records in an Access database
You can use filters to display specific records in a form, report, query, ... filter each column or control separately, or use an...
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