Skip to content

Commit 1fad00a

Browse files
yogeshbhutkaryogeshbhutkart-hamanojasmussenjarekmorawski
authored
KeyboardShortcuts: Update delete shortcut to use shift + Backspace (#68164)
* KeyboardShortcuts: Update delete shortcut to use Shift + Delete and add Backspace alias * KeyboardShortcuts: Add Shift modifier for Backspace alias * KeyboardShortcuts: Update delete shortcut character from 'del' to 'delete' * KeyboardShortcuts: Update delete shortcut to use Shift + Delete * KeyboardShortcuts: Change delete shortcut to platformAlt + Backspace * KeyboardShortcuts: Update delete shortcut to use primaryShift + Delete * KeyboardShortcuts: Update Block Locking spec to use the proper key shortcut * KeyboardShortcuts: Change delete shortcut to primaryShift + Backspace * KeyboardShortcuts: Update delete shortcut to use `shift + Backspace` Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> Co-authored-by: jarekmorawski <jarekmorawski@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
1 parent 726b4a8 commit 1fad00a

File tree

8 files changed

+23
-18
lines changed

8 files changed

+23
-18
lines changed

packages/block-editor/src/components/keyboard-shortcuts/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ function KeyboardShortcutsRegister() {
2929
category: 'block',
3030
description: __( 'Remove the selected block(s).' ),
3131
keyCombination: {
32-
modifier: 'access',
33-
character: 'z',
32+
modifier: 'shift',
33+
character: 'backspace',
3434
},
3535
} );
3636

packages/block-editor/src/components/rich-text/event-listeners/delete.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { isCollapsed, isEmpty } from '@wordpress/rich-text';
66

77
export default ( props ) => ( element ) => {
88
function onKeyDown( event ) {
9-
const { keyCode } = event;
9+
const { keyCode, shiftKey } = event;
1010

1111
if ( event.defaultPrevented ) {
1212
return;
@@ -30,6 +30,11 @@ export default ( props ) => ( element ) => {
3030
return;
3131
}
3232

33+
// Exclude shift+backspace as they are shortcuts for deleting blocks.
34+
if ( shiftKey ) {
35+
return;
36+
}
37+
3338
if ( onMerge ) {
3439
onMerge( ! isReverse );
3540
}

test/e2e/specs/editor/blocks/navigation.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ test.describe( 'Navigation block', () => {
276276
await pageUtils.pressKeys( 'ArrowDown' );
277277

278278
// remove the child link
279-
await pageUtils.pressKeys( 'access+z' );
279+
await pageUtils.pressKeys( 'shift+Backspace' );
280280

281281
const submenuBlock2 = editor.canvas.getByRole( 'document', {
282282
name: 'Block: Submenu',
@@ -494,7 +494,7 @@ test.describe( 'Navigation block', () => {
494494
await pageUtils.pressKeys( 'ArrowDown', { times: 4 } );
495495
await navigation.checkLabelFocus( 'wordpress.org' );
496496
// Delete the nav link
497-
await pageUtils.pressKeys( 'access+z' );
497+
await pageUtils.pressKeys( 'shift+Backspace' );
498498
// Focus moved to sibling
499499
await navigation.checkLabelFocus( 'Dog' );
500500
// Add a link back so we can delete the first submenu link and see if focus returns to the parent submenu item
@@ -507,15 +507,15 @@ test.describe( 'Navigation block', () => {
507507
await pageUtils.pressKeys( 'ArrowUp', { times: 2 } );
508508
await navigation.checkLabelFocus( 'Dog' );
509509
// Delete the nav link
510-
await pageUtils.pressKeys( 'access+z' );
510+
await pageUtils.pressKeys( 'shift+Backspace' );
511511
await pageUtils.pressKeys( 'ArrowDown' );
512512
// Focus moved to parent submenu item
513513
await navigation.checkLabelFocus( 'example.com' );
514514
// Deleting this should move focus to the sibling item
515-
await pageUtils.pressKeys( 'access+z' );
515+
await pageUtils.pressKeys( 'shift+Backspace' );
516516
await navigation.checkLabelFocus( 'Cat' );
517517
// Deleting with no more siblings should focus the navigation block again
518-
await pageUtils.pressKeys( 'access+z' );
518+
await pageUtils.pressKeys( 'shift+Backspace' );
519519
await expect( navBlock ).toBeFocused();
520520
// Wait until the nav block inserter is visible before we continue.
521521
await expect( navBlockInserter ).toBeVisible();

test/e2e/specs/editor/various/block-deletion.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ test.describe( 'Block deletion', () => {
134134
).toBeFocused();
135135

136136
// Remove the current paragraph via dedicated keyboard shortcut.
137-
await pageUtils.pressKeys( 'access+z' );
137+
await pageUtils.pressKeys( 'shift+Backspace' );
138138

139139
// Ensure the last block was removed.
140140
await expect.poll( editor.getBlocks ).toMatchObject( [

test/e2e/specs/editor/various/block-locking.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ test.describe( 'Block Locking', () => {
133133
).toBeVisible();
134134

135135
await paragraph.click();
136-
await pageUtils.pressKeys( 'access+z' );
136+
await pageUtils.pressKeys( 'shift+Backspace' );
137137

138138
await expect.poll( editor.getBlocks ).toMatchObject( [
139139
{

test/e2e/specs/editor/various/list-view.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ test.describe( 'List View', () => {
809809

810810
// Delete remaining blocks.
811811
// Keyboard shortcut should also work.
812-
await pageUtils.pressKeys( 'access+z' );
813-
await pageUtils.pressKeys( 'access+z' );
812+
await pageUtils.pressKeys( 'shift+Backspace' );
813+
await pageUtils.pressKeys( 'shift+Backspace' );
814814
await expect
815815
.poll(
816816
listViewUtils.getBlocksWithA11yAttributes,
@@ -842,7 +842,7 @@ test.describe( 'List View', () => {
842842
{ name: 'core/heading', selected: false },
843843
] );
844844

845-
await pageUtils.pressKeys( 'access+z' );
845+
await pageUtils.pressKeys( 'shift+Backspace' );
846846
await expect
847847
.poll(
848848
listViewUtils.getBlocksWithA11yAttributes,
@@ -865,7 +865,7 @@ test.describe( 'List View', () => {
865865
.getByRole( 'gridcell', { name: 'File' } )
866866
.getByRole( 'link' )
867867
.focus();
868-
for ( const keys of [ 'Delete', 'Backspace', 'access+z' ] ) {
868+
for ( const keys of [ 'Delete', 'Backspace', 'shift+Backspace' ] ) {
869869
await pageUtils.pressKeys( keys );
870870
await expect
871871
.poll(
@@ -1133,7 +1133,7 @@ test.describe( 'List View', () => {
11331133
optionsForFileMenu,
11341134
'Pressing Space should also open the menu dropdown'
11351135
).toBeVisible();
1136-
await pageUtils.pressKeys( 'access+z' ); // Keyboard shortcut for Delete.
1136+
await pageUtils.pressKeys( 'shift+Backspace' ); // Keyboard shortcut for Delete.
11371137
await expect
11381138
.poll(
11391139
listViewUtils.getBlocksWithA11yAttributes,
@@ -1153,7 +1153,7 @@ test.describe( 'List View', () => {
11531153
optionsForFileMenu.getByRole( 'menuitem', { name: 'Delete' } ),
11541154
'The delete menu item should be hidden for locked blocks'
11551155
).toBeHidden();
1156-
await pageUtils.pressKeys( 'access+z' );
1156+
await pageUtils.pressKeys( 'shift+Backspace' );
11571157
await expect
11581158
.poll(
11591159
listViewUtils.getBlocksWithA11yAttributes,

test/e2e/specs/site-editor/template-part.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ test.describe( 'Template Part', () => {
375375
await editor.selectBlocks( siteTitle );
376376

377377
// Remove the default site title block.
378-
await pageUtils.pressKeys( 'access+z' );
378+
await pageUtils.pressKeys( 'shift+Backspace' );
379379

380380
// Insert a group block with a Site Title block inside.
381381
await editor.insertBlock( {

test/e2e/specs/widgets/editing-widgets.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ test.describe( 'Widgets screen', () => {
573573
.getByRole( 'document', { name: 'Block: Paragraph' } )
574574
.filter( { hasText: 'Second Paragraph' } )
575575
.focus();
576-
await pageUtils.pressKeys( 'access+z' );
576+
await pageUtils.pressKeys( 'shift+Backspace' );
577577
await widgetsScreen.saveWidgets();
578578

579579
await expect.poll( widgetsScreen.getWidgetAreaBlocks ).toMatchObject( {

0 commit comments

Comments
 (0)