hook to clear text after submiting a comment

This commit is contained in:
okbel
2018-03-01 19:43:54 -03:00
parent 8192a3bfc4
commit bc273d16f7
6 changed files with 44 additions and 4 deletions
@@ -49,6 +49,6 @@ export default class CheckSpamHook extends React.Component {
CheckSpamHook.propTypes = {
notify: PropTypes.func.isRequired,
registerHook: PropTypes.func.isRequired,
unregisterHook: PropTypes.func.isRequired,
registerHook: PropTypes.func,
unregisterHook: PropTypes.func,
};
@@ -40,6 +40,18 @@ class Editor extends React.Component {
if (this.props.comment && this.props.comment.richTextBody) {
this.ref.content.innerHTML = this.props.comment.richTextBody;
}
this.clearInputHook = this.props.registerHook(
'postSubmit',
(res, handleBodyChange) => {
this.ref.content.innerHTML = '';
handleBodyChange('', { richTextBody: '' });
}
);
}
componentWillUnmount() {
this.props.unregisterHook(this.clearInputHook);
}
render() {
@@ -85,6 +97,8 @@ Editor.propTypes = {
comment: PropTypes.object,
classNames: PropTypes.object,
actions: PropTypes.array,
registerHook: PropTypes.func,
unregisterHook: PropTypes.func,
};
export default Editor;