Skip to content

Commit

Permalink
Fixed RichText placeholder whitespace.
Browse files Browse the repository at this point in the history
The RichText CSS uses a rule based on attribute data-is-placeholder-visible. The TinyMce component was just setting this attribute when componentWillReceiveProps is invoked while it should also set it after the first  mount for the first props received after TinyMce setup is complete.
  • Loading branch information
jorgefilipecosta committed Feb 13, 2018
1 parent 6619a9f commit 5b52913
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions blocks/rich-text/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ export default class TinyMCE extends Component {
return false;
}

componentWillReceiveProps( nextProps ) {
configureIsPlaceholderVisible( isPlaceholderVisible ) {
const name = 'data-is-placeholder-visible';
const isPlaceholderVisible = String( !! nextProps.isPlaceholderVisible );

if ( this.editorNode.getAttribute( name ) !== isPlaceholderVisible ) {
this.editorNode.setAttribute( name, isPlaceholderVisible );
const isPlaceholderVisibleString = String( !! isPlaceholderVisible );
if ( this.editorNode.getAttribute( name ) !== isPlaceholderVisibleString ) {
this.editorNode.setAttribute( name, isPlaceholderVisibleString );
}
}

componentWillReceiveProps( nextProps ) {
this.configureIsPlaceholderVisible( nextProps.isPlaceholderVisible );

if ( ! isEqual( this.props.style, nextProps.style ) ) {
this.editorNode.setAttribute( 'style', '' );
Expand Down Expand Up @@ -88,6 +91,7 @@ export default class TinyMCE extends Component {
setup: ( editor ) => {
this.editor = editor;
this.props.onSetup( editor );
this.configureIsPlaceholderVisible( this.props.isPlaceholderVisible );
},
} );
}
Expand Down

0 comments on commit 5b52913

Please sign in to comment.