pacocoursey / cmdk

Fast, unstyled command menu React component.
https://cmdk.paco.me
MIT License
9.98k stars 287 forks source link

Searching returns incorrect results #303

Closed dynjo closed 2 months ago

dynjo commented 2 months ago

To reproduce, go to https://cmdk.paco.me and type x

Result list shows "Figma" which does not contain an x

rollsrobby commented 2 months ago

figma has a keyword for "ux" which is why it is returned when you search for "x". So I guess this is expected.

...
<Item value="Figma" keywords={['design', 'ui', 'ux']}>
  <Logo>
    <FigmaIcon />
  </Logo>
  Figma
</Item>
...

Link to source

dynjo commented 2 months ago

Ok that makes some sense, but if I type in nn for example, I still see Slack?

<Item value="Slack" keywords={['chat', 'team', 'communication']}>
  <Logo>
    <SlackIcon />
  </Logo>
  Slack
</Item>

Perhaps because two n in communication I guess.

Though xx still returns Figma which only contains 1 x so would expect no results?

rollsrobby commented 2 months ago

I guess that has to do with the filtering algorithm that is not as straight forward as a substring search.

command-score

dynjo commented 2 months ago

Yeah, i'll close this as it seems to be more the intended behavior.