Skip to content

Commit

Permalink
Change keyboard shortcut to access + z (#10008)
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan authored Sep 21, 2018
1 parent a8bc550 commit 2ff11bd
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/reference/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ This is the canonical list of keyboard shortcuts:
### Block shortcuts

* <kbd>Shift</kbd>+<kbd>⌘D</kbd> Duplicate the selected block(s).
* <kbd>Option</kbd>+<kbd>⌘Backspace</kbd> Remove the selected block(s).
* <kbd>Ctrl</kbd>+<kbd>Option</kbd>+<kbd>z</kbd> Remove the selected block(s).
* <kbd>Option</kbd>+<kbd>⌘T</kbd> Insert a new block before the selected block(s).
* <kbd>Option</kbd>+<kbd>⌘Y</kbd> Insert a new block after the selected block(s).
* <kbd>/</kbd> Change the block type after adding a new paragraph.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const blockShortcuts = {
description: __( 'Duplicate the selected block(s).' ),
},
{
keyCombination: primaryAlt( 'backspace' ),
keyCombination: access( 'z' ),
description: __( 'Remove the selected block(s).' ),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ
Object {
"description": "Remove the selected block(s).",
"keyCombination": Array [
"Ctrl",
"Shift",
"+",
"Alt",
"+",
"Backspace",
"Z",
],
},
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const shortcuts = {
display: displayShortcut.primaryShift( 'd' ),
},
removeBlock: {
raw: rawShortcut.primaryAlt( 'backspace' ),
display: displayShortcut.primaryAlt( 'Backspace' ),
raw: rawShortcut.access( 'z' ),
display: displayShortcut.access( 'z' ),
},
insertBefore: {
raw: rawShortcut.primaryAlt( 't' ),
Expand Down
8 changes: 1 addition & 7 deletions packages/editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
getScrollContainer,
} from '@wordpress/dom';
import { createBlobURL } from '@wordpress/blob';
import { BACKSPACE, DELETE, ENTER, LEFT, RIGHT, rawShortcut, isKeyboardEvent } from '@wordpress/keycodes';
import { BACKSPACE, DELETE, ENTER, LEFT, RIGHT, rawShortcut } from '@wordpress/keycodes';
import { Slot } from '@wordpress/components';
import { withDispatch, withSelect } from '@wordpress/data';
import { rawHandler, children } from '@wordpress/blocks';
Expand Down Expand Up @@ -406,12 +406,6 @@ export class RichText extends Component {
const { keyCode } = event;
const isReverse = keyCode === BACKSPACE;

// User is using the Remove Block shortcut, so allow the event to bubble
// up to the BlockSettingsMenu component
if ( isKeyboardEvent.primaryAlt( event, 'Backspace' ) ) {
return;
}

const { isCollapsed } = getSelection();

// Only process delete if the key press occurs at uncollapsed edge.
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/block-deletion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getEditedPostContent,
newPost,
pressWithModifier,
META_KEY,
ACCESS_MODIFIER_KEYS,
} from '../support/utils';

const addThreeParagraphsToNewPost = async () => {
Expand Down Expand Up @@ -50,7 +50,7 @@ describe( 'block deletion -', () => {
it( 'results in two remaining blocks and positions the caret at the end of the second block', async () => {
// Type some text to assert that the shortcut also deletes block content.
await page.keyboard.type( 'this is block 2' );
await pressWithModifier( [ 'Alt', META_KEY ], 'Backspace' );
await pressWithModifier( ACCESS_MODIFIER_KEYS, 'z' );
expect( await getEditedPostContent() ).toMatchSnapshot();

// Type additional text and assert that caret position is correct by comparing to snapshot.
Expand Down

0 comments on commit 2ff11bd

Please sign in to comment.