Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Backspace does not seem to cause a selectionChange event, so trigger …
…the callback on keyup as well.
  • Loading branch information
ellatrix committed May 24, 2017
commit 0f55c61bc20454d824ae6da3cd514bb2a19390cb
8 changes: 8 additions & 0 deletions blocks/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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 ) {
Expand Down Expand Up @@ -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;
Expand Down