Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { BACKSPACE, DELETE } from '@wordpress/keycodes';
import isShallowEqual from '@wordpress/is-shallow-equal';
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
import { speak } from '@wordpress/a11y';
import { isTextField } from '@wordpress/dom';

/**
* Internal dependencies
Expand Down Expand Up @@ -182,10 +181,7 @@ function ListViewBlock( {
return;
}

// Retain the default behavior for text fields.
if ( isTextField( event.target ) ) {
return;
}
const isDeleteKey = [ BACKSPACE, DELETE ].includes( event.keyCode );

// If multiple blocks are selected, deselect all blocks when the user
// presses the escape key.
Expand All @@ -197,10 +193,15 @@ function ListViewBlock( {
event.preventDefault();
selectBlock( event, undefined );
} else if (
event.keyCode === BACKSPACE ||
event.keyCode === DELETE ||
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