Skip to content

Commit

Permalink
Rich Text: Determine emptiness by value
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Feb 16, 2018
1 parent 9cd9c18 commit 059d8ba
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions blocks/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ export class RichText extends Component {
formats: {},
selectedNodeId: 0,
};

this.isEmpty = ! value || ! value.length;
}

/**
Expand Down Expand Up @@ -397,8 +395,7 @@ export class RichText extends Component {
*/

onChange() {
this.isEmpty = this.editor.dom.isEmpty( this.editor.getBody() );
this.savedContent = this.isEmpty ? [] : this.getContent();
this.savedContent = this.getContent();
this.props.onChange( this.savedContent );
}

Expand Down Expand Up @@ -820,12 +817,13 @@ export class RichText extends Component {
} = this.props;

const ariaProps = pickAriaProps( this.props );
const isEmpty = ! value || ! value.length;

// Generating a key that includes `tagName` ensures that if the tag
// changes, we unmount and destroy the previous TinyMCE element, then
// mount and initialize a new child element in its place.
const key = [ 'editor', Tagname ].join();
const isPlaceholderVisible = placeholder && ( ! isSelected || keepPlaceholderOnFocus ) && this.isEmpty;
const isPlaceholderVisible = placeholder && ( ! isSelected || keepPlaceholderOnFocus ) && isEmpty;
const classes = classnames( wrapperClassName, 'blocks-rich-text' );

const formatToolbar = (
Expand Down

0 comments on commit 059d8ba

Please sign in to comment.