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

Add Support for Searching by Multiple Option Properties to ComboboxControl #68829

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

dhruvikpatel18
Copy link
Contributor

@dhruvikpatel18 dhruvikpatel18 commented Jan 22, 2025

Why?

This PR is intended to solve issue mentioned here: #68760

How?

  • Introduced a new filterKeys prop that allows specifying which properties should be considered when filtering options.
  • Updated the filtering logic to iterate through the defined properties and match against the input value.
  • Added support for partial matching across specified properties.
  • Updated the component's README documentation to reflect the new feature and usage guidelines.

Testing Instructions

  1. Open the WordPress block editor.
  2. Insert a block that uses the ComboboxControl component.
  3. Pass an array of options containing multiple properties (e.g., value, label, description).
  4. Set the filterKeys prop to ['label', 'description'].
  5. Type a query in the search input and verify that matching occurs across the specified fields.
  6. Ensure selections work correctly and the correct value is passed to the onChange handler.

Screenshots or screencast

ComboboxControl.Screencast.mov

@dhruvikpatel18 dhruvikpatel18 marked this pull request as ready for review January 22, 2025 12:13
Copy link

github-actions bot commented Jan 22, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvikpatel18 <[email protected]>
Co-authored-by: picocodes <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@@ -89,9 +92,17 @@ Function called when the control's search input value changes. The argument cont
- Type: `( value: string ) => void`
- Required: No

#### filterProperties

Choose a reason for hiding this comment

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

The actual component uses filterFields and not filterProperties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I have updated it.

@@ -40,10 +40,13 @@ function MyComboboxControl() {
value={ fontSize }
onChange={ setFontSize }
options={ filteredOptions }
filterProperties={ ['value', 'label'] }

Choose a reason for hiding this comment

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

The actual component uses filterFields and not filterProperties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I have updated it.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants