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

Export of commandScore? #295

Open
goatyeahh opened this issue Aug 5, 2024 · 3 comments
Open

Export of commandScore? #295

goatyeahh opened this issue Aug 5, 2024 · 3 comments

Comments

@goatyeahh
Copy link

Would you consider exporting commandScore? I like the default commandScore, but it would be great to reuse it.

CleanShot 2024-08-05 at 13 06 14@2x

Why?

My first use case is that I have added some unique value to my command items to avoid name clash issues that interfere with the search like suggested here #174

<Command.Item value="apple __a__">Apple</Command.Item>
<Command.Item value="apple __b__">Apple</Command.Item>

so something like this would do the trick

  filter={(value: string, search: string, keywords?: string[]) => {
    // value: `<name> __${unique}__)`
    const valueWithoutUnique = value.replace(/\s+__\s+__/, "");
    return commandScore(valueWithoutUnique, search, keywords);
  }}

or another use case would be to change filter only for some specific keyword and for others leave the default.

@EdoAPP
Copy link

EdoAPP commented Oct 9, 2024

It seems that the change it's already in the main branch https://github.com/pacocoursey/cmdk/blob/main/cmdk/src/index.tsx#L937 but the current release doesn't contain the changes. Perhaps @pacocoursey can comment on when there's an incoming release.

@muZk
Copy link

muZk commented Jan 17, 2025

I think you can use the defaultFilter exported on #229

@igor9silva
Copy link

igor9silva commented Feb 1, 2025

It's available on v1.0.4.
#229 (comment)

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

No branches or pull requests

4 participants