Skip to content

Commit

Permalink
Wire onBackSpace in RichText component (#10997)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloercoli authored and diegoreymendez committed Oct 24, 2018
1 parent 7ee8c0f commit 0601e79
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class RichText extends Component {
super( ...arguments );
this.onChange = this.onChange.bind( this );
this.onEnter = this.onEnter.bind( this );
this.onBackspace = this.onBackspace.bind( this );
this.onContentSizeChange = this.onContentSizeChange.bind( this );
this.changeFormats = this.changeFormats.bind( this );
this.toggleFormat = this.toggleFormat.bind( this );
Expand Down Expand Up @@ -183,6 +184,15 @@ export class RichText extends Component {
this.splitContent( event.nativeEvent.text, event.nativeEvent.selectionStart, event.nativeEvent.selectionEnd );
}

// eslint-disable-next-line no-unused-vars
onBackspace( event ) {
if ( ! this.props.onBackspace ) {
return;
}

this.onBackspace( event.nativeEvent.text, event.nativeEvent.selectionStart, event.nativeEvent.selectionEnd );
}

shouldComponentUpdate( nextProps ) {
if ( nextProps.tagName !== this.props.tagName ) {
this.lastEventCount = undefined;
Expand Down Expand Up @@ -269,6 +279,7 @@ export class RichText extends Component {
text={ { text: html, eventCount: this.lastEventCount } }
onChange={ this.onChange }
onEnter={ this.onEnter }
onBackspace={ this.onBackspace }
onContentSizeChange={ this.onContentSizeChange }
onActiveFormatsChange={ this.onActiveFormatsChange }
color={ 'black' }
Expand Down

0 comments on commit 0601e79

Please sign in to comment.