pacocoursey / cmdk

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

Custom filter function is ignored for items with empty string value #124

Open MaxMusing opened 1 year ago

MaxMusing commented 1 year ago

Items with value="" are always filtered out, even if a custom filter function is provided which returns a non-zero value for that item. Expected behaviour would be to prioritize the custom filter function if one is provided, rather than always filtering these items out.

I believe the issue is with the score function here, which returns 0 if value is falsy:

function score(value: string) {
  const filter = propsRef.current?.filter ?? defaultFilter
  return value ? filter(value, state.current.search) : 0
}