Skip to content

Commit

Permalink
Make sure the component rerenders when isSelected changes so FormatTo…
Browse files Browse the repository at this point in the history
…olbar is removed
  • Loading branch information
Tug committed Nov 27, 2018
1 parent c169cf5 commit 1747389
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,13 @@ export class RichText extends Component {
return value;
}

shouldComponentUpdate( nextProps, nextState ) {
if ( nextProps.tagName !== this.props.tagName ) {
shouldComponentUpdate( nextProps ) {
if ( nextProps.tagName !== this.props.tagName || nextProps.isSelected !== this.props.isSelected ) {
this.lastEventCount = undefined;
this.lastContent = undefined;
return true;
}

// Update if selection changed
if ( nextState.start !== this.state.start || nextState.end !== this.state.end ) {
return true;
}

// The check below allows us to avoid updating the content right after an `onChange` call.
// The first time the component is drawn `lastContent` and `lastEventCount ` are both undefined
if ( this.lastEventCount &&
Expand Down

0 comments on commit 1747389

Please sign in to comment.