Skip to content

Commit

Permalink
KeyboardShortcuts: Update delete shortcut to use Shift + Delete
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshbhutkar committed Dec 20, 2024
1 parent 27325fd commit e7975b3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
6 changes: 6 additions & 0 deletions packages/e2e-test-utils-playwright/src/page-utils/keycodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const COMMAND = 'meta';
*/
export const SHIFT = 'shift';

/**
* Keycode for DELETE key.
*/
export const DELETE = 'delete';

/**
* Object that contains functions that return the available modifier
* depending on platform.
Expand All @@ -44,5 +49,6 @@ export const modifiers: Record<
ctrlShift: () => [ CTRL, SHIFT ],
shift: () => [ SHIFT ],
shiftAlt: () => [ SHIFT, ALT ],
delete: () => [ DELETE ],
undefined: () => [],
};
10 changes: 5 additions & 5 deletions test/e2e/specs/editor/blocks/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ test.describe( 'Navigation block', () => {
await pageUtils.pressKeys( 'ArrowDown' );

// remove the child link
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );

const submenuBlock2 = editor.canvas.getByRole( 'document', {
name: 'Block: Submenu',
Expand Down Expand Up @@ -494,7 +494,7 @@ test.describe( 'Navigation block', () => {
await pageUtils.pressKeys( 'ArrowDown', { times: 4 } );
await navigation.checkLabelFocus( 'wordpress.org' );
// Delete the nav link
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
// Focus moved to sibling
await navigation.checkLabelFocus( 'Dog' );
// Add a link back so we can delete the first submenu link and see if focus returns to the parent submenu item
Expand All @@ -507,15 +507,15 @@ test.describe( 'Navigation block', () => {
await pageUtils.pressKeys( 'ArrowUp', { times: 2 } );
await navigation.checkLabelFocus( 'Dog' );
// Delete the nav link
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
await pageUtils.pressKeys( 'ArrowDown' );
// Focus moved to parent submenu item
await navigation.checkLabelFocus( 'example.com' );
// Deleting this should move focus to the sibling item
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
await navigation.checkLabelFocus( 'Cat' );
// Deleting with no more siblings should focus the navigation block again
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
await expect( navBlock ).toBeFocused();
// Wait until the nav block inserter is visible before we continue.
await expect( navBlockInserter ).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/block-deletion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test.describe( 'Block deletion', () => {
).toBeFocused();

// Remove the current paragraph via dedicated keyboard shortcut.
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );

// Ensure the last block was removed.
await expect.poll( editor.getBlocks ).toMatchObject( [
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/block-locking.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test.describe( 'Block Locking', () => {
).toBeVisible();

await paragraph.click();
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );

await expect.poll( editor.getBlocks ).toMatchObject( [

Check failure on line 138 in test/e2e/specs/editor/various/block-locking.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-locking.spec.js:97:2 › Block Locking › block locking supersedes template locking

1) [chromium] › editor/various/block-locking.spec.js:97:2 › Block Locking › block locking supersedes template locking Error: expect(received).toMatchObject(expected) - Expected - 0 + Received + 14 @@ -8,12 +8,26 @@ }, "innerBlocks": Array [ Object { "attributes": Object { "content": "Hello, hello", + "level": 2, }, + "innerBlocks": Array [], "name": "core/heading", + }, + Object { + "attributes": Object { + "content": "WordPress", + "dropCap": false, + "lock": Object { + "move": false, + "remove": false, + }, + }, + "innerBlocks": Array [], + "name": "core/paragraph", }, ], "name": "core/group", }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 136 | await pageUtils.pressKeys( 'shift+delete' ); 137 | > 138 | await expect.poll( editor.getBlocks ).toMatchObject( [ | ^ 139 | { 140 | name: 'core/group', 141 | attributes: { at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-locking.spec.js:138:3

Check failure on line 138 in test/e2e/specs/editor/various/block-locking.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-locking.spec.js:97:2 › Block Locking › block locking supersedes template locking

1) [chromium] › editor/various/block-locking.spec.js:97:2 › Block Locking › block locking supersedes template locking Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toMatchObject(expected) - Expected - 0 + Received + 14 @@ -8,12 +8,26 @@ }, "innerBlocks": Array [ Object { "attributes": Object { "content": "Hello, hello", + "level": 2, }, + "innerBlocks": Array [], "name": "core/heading", + }, + Object { + "attributes": Object { + "content": "WordPress", + "dropCap": false, + "lock": Object { + "move": false, + "remove": false, + }, + }, + "innerBlocks": Array [], + "name": "core/paragraph", }, ], "name": "core/group", }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 136 | await pageUtils.pressKeys( 'shift+delete' ); 137 | > 138 | await expect.poll( editor.getBlocks ).toMatchObject( [ | ^ 139 | { 140 | name: 'core/group', 141 | attributes: { at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-locking.spec.js:138:3

Check failure on line 138 in test/e2e/specs/editor/various/block-locking.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-locking.spec.js:97:2 › Block Locking › block locking supersedes template locking

1) [chromium] › editor/various/block-locking.spec.js:97:2 › Block Locking › block locking supersedes template locking Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toMatchObject(expected) - Expected - 0 + Received + 14 @@ -8,12 +8,26 @@ }, "innerBlocks": Array [ Object { "attributes": Object { "content": "Hello, hello", + "level": 2, }, + "innerBlocks": Array [], "name": "core/heading", + }, + Object { + "attributes": Object { + "content": "WordPress", + "dropCap": false, + "lock": Object { + "move": false, + "remove": false, + }, + }, + "innerBlocks": Array [], + "name": "core/paragraph", }, ], "name": "core/group", }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 136 | await pageUtils.pressKeys( 'shift+delete' ); 137 | > 138 | await expect.poll( editor.getBlocks ).toMatchObject( [ | ^ 139 | { 140 | name: 'core/group', 141 | attributes: { at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-locking.spec.js:138:3
{
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/specs/editor/various/list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,8 @@ test.describe( 'List View', () => {

// Delete remaining blocks.
// Keyboard shortcut should also work.
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
await pageUtils.pressKeys( 'shift+delete' );
await expect
.poll(
listViewUtils.getBlocksWithA11yAttributes,
Expand Down Expand Up @@ -842,7 +842,7 @@ test.describe( 'List View', () => {
{ name: 'core/heading', selected: false },
] );

await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
await expect

Check failure on line 846 in test/e2e/specs/editor/various/list-view.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[chromium] › editor/various/list-view.spec.js:499:2 › List View › should cut

1) [chromium] › editor/various/list-view.spec.js:499:2 › List View › should cut, copy, paste, select, duplicate, insert, delete, and deselect blocks using keyboard Error: Deleting blocks without existing selection will not select blocks expect(received).toMatchObject(expected) - Expected - 2 + Received + 2 Array [ Object { "focused": true, - "name": "core/heading", - "selected": false, + "name": "core/paragraph", + "selected": true, }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 844 | 845 | await pageUtils.pressKeys( 'shift+delete' ); > 846 | await expect | ^ 847 | .poll( 848 | listViewUtils.getBlocksWithA11yAttributes, 849 | 'Deleting blocks without existing selection will not select blocks' at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/list-view.spec.js:846:3

Check failure on line 846 in test/e2e/specs/editor/various/list-view.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[chromium] › editor/various/list-view.spec.js:499:2 › List View › should cut

1) [chromium] › editor/various/list-view.spec.js:499:2 › List View › should cut, copy, paste, select, duplicate, insert, delete, and deselect blocks using keyboard Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Deleting blocks without existing selection will not select blocks expect(received).toMatchObject(expected) - Expected - 2 + Received + 2 Array [ Object { "focused": true, - "name": "core/heading", - "selected": false, + "name": "core/paragraph", + "selected": true, }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 844 | 845 | await pageUtils.pressKeys( 'shift+delete' ); > 846 | await expect | ^ 847 | .poll( 848 | listViewUtils.getBlocksWithA11yAttributes, 849 | 'Deleting blocks without existing selection will not select blocks' at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/list-view.spec.js:846:3

Check failure on line 846 in test/e2e/specs/editor/various/list-view.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[chromium] › editor/various/list-view.spec.js:499:2 › List View › should cut

1) [chromium] › editor/various/list-view.spec.js:499:2 › List View › should cut, copy, paste, select, duplicate, insert, delete, and deselect blocks using keyboard Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Deleting blocks without existing selection will not select blocks expect(received).toMatchObject(expected) - Expected - 2 + Received + 2 Array [ Object { "focused": true, - "name": "core/heading", - "selected": false, + "name": "core/paragraph", + "selected": true, }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 844 | 845 | await pageUtils.pressKeys( 'shift+delete' ); > 846 | await expect | ^ 847 | .poll( 848 | listViewUtils.getBlocksWithA11yAttributes, 849 | 'Deleting blocks without existing selection will not select blocks' at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/list-view.spec.js:846:3
.poll(
listViewUtils.getBlocksWithA11yAttributes,
Expand All @@ -865,7 +865,7 @@ test.describe( 'List View', () => {
.getByRole( 'gridcell', { name: 'File' } )
.getByRole( 'link' )
.focus();
for ( const keys of [ 'Delete', 'Backspace', 'access+z' ] ) {
for ( const keys of [ 'Delete', 'Backspace', 'shift+delete' ] ) {
await pageUtils.pressKeys( keys );
await expect
.poll(
Expand Down Expand Up @@ -1133,7 +1133,7 @@ test.describe( 'List View', () => {
optionsForFileMenu,
'Pressing Space should also open the menu dropdown'
).toBeVisible();
await pageUtils.pressKeys( 'access+z' ); // Keyboard shortcut for Delete.
await pageUtils.pressKeys( 'shift+delete' ); // Keyboard shortcut for Delete.
await expect
.poll(
listViewUtils.getBlocksWithA11yAttributes,
Expand All @@ -1153,7 +1153,7 @@ test.describe( 'List View', () => {
optionsForFileMenu.getByRole( 'menuitem', { name: 'Delete' } ),
'The delete menu item should be hidden for locked blocks'
).toBeHidden();
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
await expect
.poll(
listViewUtils.getBlocksWithA11yAttributes,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/site-editor/template-part.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ test.describe( 'Template Part', () => {
await editor.selectBlocks( siteTitle );

// Remove the default site title block.
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );

// Insert a group block with a Site Title block inside.
await editor.insertBlock( {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/widgets/editing-widgets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ test.describe( 'Widgets screen', () => {
.getByRole( 'document', { name: 'Block: Paragraph' } )
.filter( { hasText: 'Second Paragraph' } )
.focus();
await pageUtils.pressKeys( 'access+z' );
await pageUtils.pressKeys( 'shift+delete' );
await widgetsScreen.saveWidgets();

await expect.poll( widgetsScreen.getWidgetAreaBlocks ).toMatchObject( {
Expand Down

0 comments on commit e7975b3

Please sign in to comment.