Documentation: Select with search field
See original GitHub issueHello,
The documentation of the Select Component explains how to search among differents options. The ‘Select with search field’ example shows:
<Select
showSearch
style={{ width: 200 }}
placeholder="Select a person"
optionFilterProp="children"
onChange={handleChange}
filterOption={(input, option) => option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0}
>
<Option value="jack">Jack</Option>
<Option value="lucy">Lucy</Option>
<Option value="tom">Tom</Option>
</Select>
The filter option is right in this example:
filterOption={(input, option) => option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0}
But, it’s right because the value and the children match. However, if they are different it won’t work 😢
In my humble opinion, I think this example is more accurate (and more useful!):
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
What do you think about it?
Best regards, Aaron Planell
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Bootstrap Select dropdown with search - free examples & tutorial
Responsive Select dropdown with search built with Bootstrap 5. Helps you find the options you are looking for by searching.
Read more >Add a Category Select Dropdown Box to Search Form
Based on the default search form provided by WordPress, this form outputs a field for the search query, a select box containing all...
Read more ><select>: The HTML Select element - HTML - MDN Web Docs
This Boolean attribute indicates that multiple options can be selected in the list. If it is not specified, then only one option can...
Read more >Search | Select2 - The jQuery replacement for select boxes
Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and pagination (infinite scrolling) of results.
Read more >Use fields to search - Splunk Documentation
To add fields to the Selected Fields list, click All Fields at the top of the Fields sidebar. The Select Fields dialog box...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, got your point, could you send a PR?
Hi @yesmeck !
I totally agree, but maybe it’s a little bit confusing. Probably it will be more useful with
children
instead ofvalue
and it will work the same way. I think other developers will enjoy this update at the documentation.Best regards!