Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmdk/src/command-score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
5 changes: 4 additions & 1 deletion test/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Page = () => {
<Command.Item
keywords={['key']}
onSelect={() => {
;(window as any).onSelect = 'Item selected'
; (window as any).onSelect = 'Item selected'
}}
className="item"
>
Expand All @@ -19,6 +19,9 @@ const Page = () => {
<Command.Item value="xxx" className="item">
Value
</Command.Item>
<Command.Item value="Café" className="item">
Café
</Command.Item>
</Command.List>
</Command>
</div>
Expand Down