From e1284e3f6bbfa23eca68908942c51ecbf125b2ed Mon Sep 17 00:00:00 2001 From: Ayush Date: Fri, 6 Feb 2026 09:53:53 +0530 Subject: [PATCH] fix(filter): remove unicode diacritics in default matcher --- cmdk/src/command-score.ts | 7 +++++-- test/basic.test.ts | 5 +++++ test/pages/index.tsx | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmdk/src/command-score.ts b/cmdk/src/command-score.ts index bd46cc8b..7b73a85c 100644 --- a/cmdk/src/command-score.ts +++ b/cmdk/src/command-score.ts @@ -148,8 +148,11 @@ function commandScoreInner( } function formatInput(string) { - // convert all valid space characters to space so they match each other - return string.toLowerCase().replace(COUNT_SPACE_REGEXP, ' ') + return string + .toLowerCase() + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') + .replace(COUNT_SPACE_REGEXP, ' ') } export function commandScore(string: string, abbreviation: string, aliases: string[]): number { diff --git a/test/basic.test.ts b/test/basic.test.ts index 107865f0..17f0337d 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -72,4 +72,9 @@ test.describe('basic behavior', async () => { await expect(page.locator(`.item`)).toHaveCount(0) await expect(page.locator(`.empty`)).toHaveCount(1) }) + test('matches accented characters with ascii input', async ({ page }) => { + const input = page.locator('[cmdk-input]') + await input.fill('cafe') + await expect(page.locator(`[cmdk-item][data-value="Café"]`)).toHaveCount(1) + }) }) diff --git a/test/pages/index.tsx b/test/pages/index.tsx index 0bab4f1c..b2e0e223 100644 --- a/test/pages/index.tsx +++ b/test/pages/index.tsx @@ -10,7 +10,7 @@ const Page = () => { { - ;(window as any).onSelect = 'Item selected' + ; (window as any).onSelect = 'Item selected' }} className="item" > @@ -19,6 +19,9 @@ const Page = () => { Value + + Café +