feat(core-ui): Add searchMatcher prop to CompactSelect#108714
Merged
feat(core-ui): Add searchMatcher prop to CompactSelect#108714
Conversation
Allow callers to provide a custom match function via the new searchMatcher prop. When provided, it replaces the built-in case-insensitive substring matching so callers can implement arbitrary logic (e.g. suffix matching, fuzzy search, matching on non-label fields). The function receives the full option object and the current search string, returning true when the option should be visible. Co-Authored-By: Claude <noreply@anthropic.com>
Add tests verifying that: - clearing the search input restores the full option list - closing and reopening the menu resets the search query and shows all options Both ListBox and GridList variants are covered. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
natemoo-re
approved these changes
Feb 23, 2026
Comment on lines
+180
to
+186
| /** | ||
| * Custom function to determine whether an option matches the search query (applicable | ||
| * only when `searchable` is true). Receives the option and the current search string, | ||
| * and should return true if the option matches. If not provided, defaults to | ||
| * case-insensitive substring matching on `textValue` or `label`. | ||
| */ | ||
| searchMatcher?: (option: SelectOptionWithKey<SelectKey>, search: string) => boolean; |
Member
There was a problem hiding this comment.
Instead of adding new props that require searchable (like <CompactSelect searchable searchMatcher={fn} searchPlaceholder={t("Search...")} />), did you consider an object form to handle search-related configuration?
search: false | { matcher: fn, placeholder: t('Search...') }
Member
Author
There was a problem hiding this comment.
I punted consolidation for a different time, but yeah, all of these are becoming weird. Ideally, we could just expose the input component and have it do the internal state calls. I'll try think of this a bit with the subsequent work on these filter components, I'm starting to see some more patterns emerge
JonasBa
added a commit
that referenced
this pull request
Feb 23, 2026
…ing (#108719) Stacked on #108714. Extends the `searchMatcher` prop introduced in the base PR so it can optionally return a `SearchMatchResult` object in addition to a plain `boolean`. ```ts interface SearchMatchResult { score: number; } ``` When a matcher returns `SearchMatchResult`, the option is shown and its `score` is used to sort matching options — higher scores appear first. Returning `false` still hides the option. Returning `true` (the existing behaviour) shows it with no ordering influence, so the change is fully additive. --- **Update**: `searchMatcher` now always returns `SearchMatchResult` — the `boolean` return path is removed. A score > 0 means the option matches; score <= 0 hides it. The default implementation returns `{score: 1}` for a substring match and `{score: 0}` otherwise. Sorting is only triggered when a custom `searchMatcher` is provided, so the default path pays no extra cost. Sorting is scoped: within each section for sectioned lists, and globally for flat lists. Options with equal scores maintain their original relative order (stable sort). The `SearchMatchResult` type and the new `getSortedItems` utility are exported from the package for callers building custom composite selects. --------- Co-authored-by: Claude <noreply@anthropic.com>
mchen-sentry
pushed a commit
that referenced
this pull request
Feb 24, 2026
Add a `searchMatcher` prop to `CompactSelect` (and `CompositeSelect`) that lets callers replace the built-in search filtering with a matcher. This will enable us to provide better searching capabilities like fuzzy searching --------- Co-authored-by: Claude <noreply@anthropic.com>
mchen-sentry
pushed a commit
that referenced
this pull request
Feb 24, 2026
…ing (#108719) Stacked on #108714. Extends the `searchMatcher` prop introduced in the base PR so it can optionally return a `SearchMatchResult` object in addition to a plain `boolean`. ```ts interface SearchMatchResult { score: number; } ``` When a matcher returns `SearchMatchResult`, the option is shown and its `score` is used to sort matching options — higher scores appear first. Returning `false` still hides the option. Returning `true` (the existing behaviour) shows it with no ordering influence, so the change is fully additive. --- **Update**: `searchMatcher` now always returns `SearchMatchResult` — the `boolean` return path is removed. A score > 0 means the option matches; score <= 0 hides it. The default implementation returns `{score: 1}` for a substring match and `{score: 0}` otherwise. Sorting is only triggered when a custom `searchMatcher` is provided, so the default path pays no extra cost. Sorting is scoped: within each section for sectioned lists, and globally for flat lists. Options with equal scores maintain their original relative order (stable sort). The `SearchMatchResult` type and the new `getSortedItems` utility are exported from the package for callers building custom composite selects. --------- Co-authored-by: Claude <noreply@anthropic.com>
wedamija
pushed a commit
that referenced
this pull request
Feb 24, 2026
Add a `searchMatcher` prop to `CompactSelect` (and `CompositeSelect`) that lets callers replace the built-in search filtering with a matcher. This will enable us to provide better searching capabilities like fuzzy searching --------- Co-authored-by: Claude <noreply@anthropic.com>
wedamija
pushed a commit
that referenced
this pull request
Feb 24, 2026
…ing (#108719) Stacked on #108714. Extends the `searchMatcher` prop introduced in the base PR so it can optionally return a `SearchMatchResult` object in addition to a plain `boolean`. ```ts interface SearchMatchResult { score: number; } ``` When a matcher returns `SearchMatchResult`, the option is shown and its `score` is used to sort matching options — higher scores appear first. Returning `false` still hides the option. Returning `true` (the existing behaviour) shows it with no ordering influence, so the change is fully additive. --- **Update**: `searchMatcher` now always returns `SearchMatchResult` — the `boolean` return path is removed. A score > 0 means the option matches; score <= 0 hides it. The default implementation returns `{score: 1}` for a substring match and `{score: 0}` otherwise. Sorting is only triggered when a custom `searchMatcher` is provided, so the default path pays no extra cost. Sorting is scoped: within each section for sectioned lists, and globally for flat lists. Options with equal scores maintain their original relative order (stable sort). The `SearchMatchResult` type and the new `getSortedItems` utility are exported from the package for callers building custom composite selects. --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
searchMatcherprop toCompactSelect(andCompositeSelect) that lets callers replace the built-in search filtering with a matcher. This will enable us to provide better searching capabilities like fuzzy searching