Skip to content

Commit

Permalink
List View: Respect default shortcuts in modals (#62479)
Browse files Browse the repository at this point in the history
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: mcsf <mcsf@git.wordpress.org>
Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org>
  • Loading branch information
6 people authored and ellatrix committed Jun 18, 2024
1 parent fa06a7f commit 3c7bf59
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ function ListViewBlock( {
return;
}

// Do not handle events if it comes from modals;
// retain the default behavior for these keys.
if ( event.target.closest( '[role=dialog]' ) ) {
return;
}

const isDeleteKey = [ BACKSPACE, DELETE ].includes( event.keyCode );

// If multiple blocks are selected, deselect all blocks when the user
Expand All @@ -196,12 +202,6 @@ function ListViewBlock( {
isDeleteKey ||
isMatch( 'core/block-editor/remove', event )
) {
// Do not handle single-key block deletion shortcuts when events come from modals;
// retain the default behavior for these keys.
if ( isDeleteKey && event.target.closest( '[role=dialog]' ) ) {
return;
}

const {
blocksToUpdate: blocksToDelete,
firstBlockClientId,
Expand Down

0 comments on commit 3c7bf59

Please sign in to comment.