From 56b0ccb9a242b9c8cfae1ebfdbc62348501e21aa Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Wed, 13 Mar 2024 14:35:35 -0500 Subject: [PATCH] Prevent default on primary+k to prevent command center from opening The command center shortcut checks for defaultPrevented to see if it should open or not. To prevent the command center from opening, we need to add event.preventDefault when primary+k is used. --- packages/block-library/src/navigation-link/edit.js | 1 + packages/block-library/src/navigation-submenu/edit.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index e091b52c68a5c4..bc772671219fe9 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -333,6 +333,7 @@ export default function NavigationLinkEdit( { isKeyboardEvent.primary( event, 'k' ) || ( ( ! url || isDraft || isInvalid ) && event.keyCode === ENTER ) ) { + event.preventDefault(); setIsLinkOpen( true ); } } diff --git a/packages/block-library/src/navigation-submenu/edit.js b/packages/block-library/src/navigation-submenu/edit.js index 507ea64940c3a6..401d9512797b09 100644 --- a/packages/block-library/src/navigation-submenu/edit.js +++ b/packages/block-library/src/navigation-submenu/edit.js @@ -279,6 +279,7 @@ export default function NavigationSubmenuEdit( { function onKeyDown( event ) { if ( isKeyboardEvent.primary( event, 'k' ) ) { + event.preventDefault(); setIsLinkOpen( true ); } }