Closed itaikeren closed 8 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
cmdk-website | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jul 18, 2023 9:19am |
half a year later
While this is pending review, here's a workaround I'm using:
<Command
filter={(value, search) => {
const extendValue = `${value} ${getKeywords(value).join(' ')}`;
if (extendValue.includes(search)) return 1
return 0
}}
/>
Then you can define getKeywords(value: string): string[]
as desired. Example for my usecase:
const getKeywords = (value: string) => {
const keywords: string[] = [];
const foundItem = items.find(
// `toLowerCase()` is needed because `value` is normalized as lowercase (per the documentation)
(item) => item.name.toLowerCase() === value,
);
if (foundItem) {
keywords.push(foundItem.cpf);
}
return keywords;
};
@pacocoursey FYI this feature isn't released. The release v0.2.1 was made right before merging this PR.
This PR adds the
keywords
prop to theItem
component.Closes #146