instructure-react / react-tinymce

React TinyMCE component
181 stars 115 forks source link

navigating away from page without pagerefresh causes tinymce not to rerender #17

Open rubenring opened 8 years ago

rubenring commented 8 years ago

Issue when im using a frontend routing service and navigating to a new page and then coming back to the page with the editor. It does not rerender properly.

found this: http://stackoverflow.com/questions/29169158/react-html-editor-tinymce

athaeryn commented 8 years ago

This sounds like an issue I ran into. I have an interface where a user can add, remove, and reorder multiple pages of content. Changing the order of the pages caused the TinyMCE component to become unselectable.

What I did to work around it was this:

// If the page index changes, we need to kill TinyMCE...
componentWillReceiveProps(props) {
  if (props.index !== this.props.index) {
    this.refs.tinymce._remove()
  }
}
// ...and then bring it back.
componentDidUpdate (props) {
  if (props.index !== this.props.index) {
    this.refs.tinymce.componentDidMount()
  }
}

This worked, but is a pretty big hack.