From dc453b3821b11485911ada0dc872dc60cce5bb70 Mon Sep 17 00:00:00 2001 From: Ella Date: Wed, 24 May 2017 16:14:11 +0200 Subject: [PATCH] Backspace does not trigger selectionChange event in Chrome (#883) Trigger the callback on keyup as well. This is a bug in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=725890 --- blocks/editable/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/blocks/editable/index.js b/blocks/editable/index.js index d090d57410cc3..6e8e93c99acf7 100644 --- a/blocks/editable/index.js +++ b/blocks/editable/index.js @@ -74,6 +74,7 @@ export default class Editable extends wp.element.Component { this.onFocus = this.onFocus.bind( this ); this.onNodeChange = this.onNodeChange.bind( this ); this.onKeyDown = this.onKeyDown.bind( this ); + this.onKeyUp = this.onKeyUp.bind( this ); this.changeFormats = this.changeFormats.bind( this ); this.onSelectionChange = this.onSelectionChange.bind( this ); @@ -100,6 +101,7 @@ export default class Editable extends wp.element.Component { editor.on( 'focusin', this.onFocus ); editor.on( 'nodechange', this.onNodeChange ); editor.on( 'keydown', this.onKeyDown ); + editor.on( 'keyup', this.onKeyUp ); editor.on( 'selectionChange', this.onSelectionChange ); if ( this.props.onSetup ) { @@ -231,6 +233,12 @@ export default class Editable extends wp.element.Component { } } + onKeyUp( { keyCode } ) { + if ( keyCode === KEYCODE_BACKSPACE ) { + this.onSelectionChange(); + } + } + onNewBlock() { if ( this.props.tagName || ! this.props.onSplit ) { return;