Skip to content

Commit 3f15fdb

Browse files
非凡少年francoischalifour
非凡少年
andauthored
fix: support Chrome autofill when event.key is undefined (#1888)
* fix: event.key is undefined #1887 * Update packages/docsearch-react/src/useDocSearchKeyboardEvents.ts Co-authored-by: François Chalifour <francoischalifour@users.noreply.github.com> --------- Co-authored-by: François Chalifour <francoischalifour@users.noreply.github.com>
1 parent bae117c commit 3f15fdb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ dist/
1515

1616
# IDE
1717
.vscode/
18+
.idea
1819

1920
# Environment files
2021
.env
2122

2223
# Cypress Video and Screenshots output
2324
cypress/screenshots/
24-
cypress/videos/
25+
cypress/videos/

packages/docsearch-react/src/useDocSearchKeyboardEvents.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ export function useDocSearchKeyboardEvents({
3939
if (
4040
(event.keyCode === 27 && isOpen) ||
4141
// The `Cmd+K` shortcut both opens and closes the modal.
42-
(event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) ||
42+
// We need to check for `event.key` because it can be `undefined` with
43+
// Chrome's autofill feature.
44+
// See https://github.com/paperjs/paper.js/issues/1398
45+
(event.key?.toLowerCase() === 'k' &&
46+
(event.metaKey || event.ctrlKey)) ||
4347
// The `/` shortcut opens but doesn't close the modal because it's
4448
// a character.
4549
(!isEditingContent(event) && event.key === '/' && !isOpen)

0 commit comments

Comments
 (0)