cmdk icon indicating copy to clipboard operation
cmdk copied to clipboard

Normalize search value by converting extended Latin to regular Latin

Open misha-erm opened this issue 2 years ago • 1 comments

Hello,

In my scenario items for commands menu can be added by users and that means they can use their native language. Should cmdk also take this into account when filtering items? (fyi: lodash's method for reference https://lodash.com/docs/4.17.15#deburr )

I know that I can pass my own filter function to cmdk and I would be totally fine with this approach if cmdk exported defult scoring function so I can prepare value and benefit from default scoring function

Thank you in advance

misha-erm avatar Aug 17 '23 10:08 misha-erm

The default filter is actually exported, so just wrapping it works for me:

import { defaultFilter } from "cmdk"

function defaultNormalizedFilter(
  value: string,
  search: string,
  keywords?: string[]
) {
  // Keywords can be normalized here or before passing them to Command.Item
  return defaultFilter(normalize(value), normalize(search), keywords)
}

SebKranz avatar May 22 '25 12:05 SebKranz