Skip to content

Commit

Permalink
Merge pull request #2930 from marmelab/fix-tich-text-input-update
Browse files Browse the repository at this point in the history
Fix RichTextInput does not update when content is changed outside the editor
  • Loading branch information
Gildas Garcia committed Feb 26, 2019
2 parents e6d9714 + 2e221ca commit 0062aa9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/ra-input-rich-text/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ export class RichTextInput extends Component {
this.quill.on('text-change', debounce(this.onTextChange, 500));
}

componentDidUpdate(prevProps) {
if (prevProps.input.value !== this.props.input.value) {
const selection = this.quill.getSelection();
this.quill.setContents(
this.quill.clipboard.convert(this.props.input.value)
);
if (selection && this.quill.hasFocus()) {
this.quill.setSelection(selection);
}
}
}

componentWillUnmount() {
this.quill.off('text-change', this.onTextChange);
this.quill = null;
Expand Down

0 comments on commit 0062aa9

Please sign in to comment.