Skip to content

Commit

Permalink
Use isKeyboardEvent to catch key combination + improve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Aug 13, 2018
1 parent 46ccb19 commit 178325e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 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 } from '@wordpress/keycodes';
import { BACKSPACE, DELETE, ENTER, LEFT, RIGHT, rawShortcut, isKeyboardEvent } from '@wordpress/keycodes';
import { Slot } from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { rawHandler, children } from '@wordpress/blocks';
Expand Down Expand Up @@ -397,11 +397,12 @@ export class RichText extends Component {
return;
}

const { keyCode, altKey, metaKey } = event;
const { keyCode } = event;
const isReverse = keyCode === BACKSPACE;

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

Expand Down

0 comments on commit 178325e

Please sign in to comment.