Skip to content

Commit

Permalink
List View: Respect default shortcuts in modals (WordPress#62479)
Browse files Browse the repository at this point in the history
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: andrewserong <[email protected]>
Co-authored-by: mcsf <[email protected]>
Co-authored-by: colorful-tones <[email protected]>
  • Loading branch information
6 people authored and patil-vipul committed Jun 17, 2024
1 parent 2f80d5c commit f4a6777
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 f4a6777

Please sign in to comment.