Skip to content

Commit

Permalink
Prevent default on primary+k to prevent command center from opening (W…
Browse files Browse the repository at this point in the history
…ordPress#59845)

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.
  • Loading branch information
jeryj authored and carstingaxion committed Mar 27, 2024
1 parent f872833 commit e1f0504
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export default function NavigationLinkEdit( {
isKeyboardEvent.primary( event, 'k' ) ||
( ( ! url || isDraft || isInvalid ) && event.keyCode === ENTER )
) {
event.preventDefault();
setIsLinkOpen( true );
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/navigation-submenu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export default function NavigationSubmenuEdit( {

function onKeyDown( event ) {
if ( isKeyboardEvent.primary( event, 'k' ) ) {
event.preventDefault();
setIsLinkOpen( true );
}
}
Expand Down

0 comments on commit e1f0504

Please sign in to comment.