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

Dropdown component label search #2110

Merged
merged 10 commits into from
Jul 13, 2022
Merged

Dropdown component label search #2110

merged 10 commits into from
Jul 13, 2022

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Jun 29, 2022

Add search prop for the options of dcc.Dropdown. Fix #2108

  • Use if the label is a component or provide a custom search value different from the label.
  • If no search value and the label is a component, the value will be used for search.

@T4rk1n T4rk1n changed the title Dropdown component label search [WIP] Dropdown component label search Jun 30, 2022
let labelKey = 'label';
if (firstOption && firstOption.search) {
labelKey = 'search';
} else if (firstOption && React.isValidElement(firstOption.label)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see people using strings for some options and components for others - like if they want a few options to have custom font color but others just use the default behavior. So just looking at the first one may not be robust. Also wondering if there's a way to pull the text out of a component for the same use case, particularly when the value is encoded in a way that isn't useful for searching (matching names to ID numbers or something). But it could still be nice to search on value too, especially if the search would match EITHER label or value. Is that possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it could still be nice to search on value too, especially if the search would match EITHER label or value. Is that possible?

It's possible to add field indexes to the search, maybe we should add a new prop search_indexes, then it could match any field in a dictionary of options ?

@T4rk1n T4rk1n changed the title [WIP] Dropdown component label search Dropdown component label search Jul 4, 2022
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃

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

Successfully merging this pull request may close these issues.

[BUG] Styling Components as Option Labels Destroys Search
2 participants