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.

Documentation: Select with search field

See original GitHub issue

Hello,

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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
yesmeckcommented, Jun 8, 2017

Oh, got your point, could you send a PR?

1reaction
aaronplanellcommented, Jun 7, 2017

Hi @yesmeck !

I totally agree, but maybe it’s a little bit confusing. Probably it will be more useful with children instead of value and it will work the same way. I think other developers will enjoy this update at the documentation.

Best regards!

Read more comments on GitHub >

github_iconTop 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 >

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