Skip to content

Commit

Permalink
Fix Editable tagName changes after #635
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 4, 2017
1 parent fea2a89 commit b8e2ce4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 0 additions & 4 deletions blocks/components/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,6 @@ export default class Editable extends wp.element.Component {
}

componentDidUpdate( prevProps ) {
if ( this.props.tagName !== prevProps.tagName ) {
this.initialize();
}

if ( !! this.props.focus && ! prevProps.focus ) {
this.focus();
}
Expand Down
16 changes: 13 additions & 3 deletions blocks/components/editable/tinymce.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class TinyMCE extends wp.element.Component {
componentDidMount() {
initialize() {
tinymce.init( {
target: this.editorNode,
theme: false,
Expand All @@ -19,12 +19,22 @@ export default class TinyMCE extends wp.element.Component {
}
}

shouldComponentUpdate() {
componentDidMount() {
this.initialize();
}

componentDidUpdate( prevProps ) {
if ( this.props.tagName !== prevProps.tagName ) {
this.initialize();
}
}

shouldComponentUpdate( nextProps ) {
// We must prevent rerenders because TinyMCE will modify the DOM, thus
// breaking React's ability to reconcile changes.
//
// See: https://github.com/facebook/react/issues/6802
return false;
return nextProps.tagName !== this.props.tagName;
}

render() {
Expand Down

0 comments on commit b8e2ce4

Please sign in to comment.