@@ -30,7 +30,6 @@ import { BACKSPACE, DELETE } from '@wordpress/keycodes';
30
30
import isShallowEqual from '@wordpress/is-shallow-equal' ;
31
31
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts' ;
32
32
import { speak } from '@wordpress/a11y' ;
33
- import { isTextField } from '@wordpress/dom' ;
34
33
35
34
/**
36
35
* Internal dependencies
@@ -182,10 +181,7 @@ function ListViewBlock( {
182
181
return ;
183
182
}
184
183
185
- // Retain the default behavior for text fields.
186
- if ( isTextField ( event . target ) ) {
187
- return ;
188
- }
184
+ const isDeleteKey = [ BACKSPACE , DELETE ] . includes ( event . keyCode ) ;
189
185
190
186
// If multiple blocks are selected, deselect all blocks when the user
191
187
// presses the escape key.
@@ -197,10 +193,15 @@ function ListViewBlock( {
197
193
event . preventDefault ( ) ;
198
194
selectBlock ( event , undefined ) ;
199
195
} else if (
200
- event . keyCode === BACKSPACE ||
201
- event . keyCode === DELETE ||
196
+ isDeleteKey ||
202
197
isMatch ( 'core/block-editor/remove' , event )
203
198
) {
199
+ // Do not handle single-key block deletion shortcuts when events come from modals;
200
+ // retain the default behavior for these keys.
201
+ if ( isDeleteKey && event . target . closest ( '[role=dialog]' ) ) {
202
+ return ;
203
+ }
204
+
204
205
const {
205
206
blocksToUpdate : blocksToDelete ,
206
207
firstBlockClientId,
0 commit comments