Skip to content

Commit

Permalink
Classic Block: fix undo keyboard shortcut (#23376)
Browse files Browse the repository at this point in the history
* Prevent gutenberg undo from kicking in when in classic block
Co-authored-by: Glen Davies <glen.davies@a8c.com>
  • Loading branch information
glendaviesnz committed Jun 29, 2020
1 parent 3366fbe commit 6676de7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/block-library/src/classic/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { debounce } from 'lodash';
*/
import { Component } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
import { BACKSPACE, DELETE, F10 } from '@wordpress/keycodes';
import { BACKSPACE, DELETE, F10, isKeyboardEvent } from '@wordpress/keycodes';

const { wp } = window;

Expand Down Expand Up @@ -136,6 +136,11 @@ export default class ClassicEdit extends Component {
);

editor.on( 'keydown', ( event ) => {
if ( isKeyboardEvent.primary( event, 'z' ) ) {
// Prevent the gutenberg undo kicking in so TinyMCE undo stack works as expected
event.stopPropagation();
}

if (
( event.keyCode === BACKSPACE || event.keyCode === DELETE ) &&
isTmceEmpty( editor )
Expand Down

0 comments on commit 6676de7

Please sign in to comment.