From 5a1469197f33f62217ef015924d20be6190d463d Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Thu, 6 Oct 2022 12:15:05 +0300 Subject: [PATCH 1/2] fix: enable `Cmd+K` shortcut when caps lock is on --- packages/docsearch-react/src/useDocSearchKeyboardEvents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts index 8a9919456..0e660eb99 100644 --- a/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts +++ b/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts @@ -39,7 +39,7 @@ export function useDocSearchKeyboardEvents({ if ( (event.keyCode === 27 && isOpen) || // The `Cmd+K` shortcut both opens and closes the modal. - (event.key === 'k' && (event.metaKey || event.ctrlKey)) || + (event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) || // The `/` shortcut opens but doesn't close the modal because it's // a character. (!isEditingContent(event) && event.key === '/' && !isOpen) From cc8688b378912ee21effc4e6d83e8e06f925a26e Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Sun, 23 Oct 2022 10:35:10 +0300 Subject: [PATCH 2/2] Add tests --- cypress/integration/search/actions.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cypress/integration/search/actions.spec.ts b/cypress/integration/search/actions.spec.ts index 162e490d1..d8c109ef6 100644 --- a/cypress/integration/search/actions.spec.ts +++ b/cypress/integration/search/actions.spec.ts @@ -15,11 +15,21 @@ describe('Start', () => { cy.modalIsVisibleAndFocused(); }); + it('Open modal with key shortcut on Windows/Linux when caps lock is on', () => { + cy.get('body').type('{ctrl}K'); + cy.modalIsVisibleAndFocused(); + }); + it('Open modal with key shortcut on macOS', () => { cy.get('body').type('{meta}k'); cy.modalIsVisibleAndFocused(); }); + it('Open modal with key shortcut on macOS when caps lock is on', () => { + cy.get('body').type('{meta}K'); + cy.modalIsVisibleAndFocused(); + }); + it('Open modal with forward slash key shortcut', () => { cy.get('body').type('/'); cy.modalIsVisibleAndFocused();