diff --git a/lib/site/topic-layout/topic-article/comments/form/autogrow-textarea.js b/lib/site/topic-layout/topic-article/comments/form/autogrow-textarea.js
index c1e461637e..3bd7a5ab56 100644
--- a/lib/site/topic-layout/topic-article/comments/form/autogrow-textarea.js
+++ b/lib/site/topic-layout/topic-article/comments/form/autogrow-textarea.js
@@ -1,5 +1,4 @@
import React, {Component} from 'react'
-import {findDOMNode} from 'react-dom'
export default class AutoGrowTextarea extends Component {
componentDidMount () {
@@ -15,14 +14,14 @@ export default class AutoGrowTextarea extends Component {
}
recomputeSize = () => {
- const node = findDOMNode(this)
+ const node = this.refs.textarea
node.style.minHeight = 'auto'
node.style.minHeight = `${node.scrollHeight}px`
}
render () {
return (
-
+
)
}
}
diff --git a/lib/site/topic-layout/topic-article/comments/form/component.js b/lib/site/topic-layout/topic-article/comments/form/component.js
index 3040d6504a..7914b39037 100644
--- a/lib/site/topic-layout/topic-article/comments/form/component.js
+++ b/lib/site/topic-layout/topic-article/comments/form/component.js
@@ -47,11 +47,20 @@ class CommentsForm extends Component {
}
handleTextChange = (evt) => {
+ const text = evt.currentTarget.value || ''
+
this.setState({
- text: evt.currentTarget.value || ''
+ text: text,
+ focused: text ? true : this.state.focused
})
}
+ handleKeyDown = (evt) => {
+ if ((evt.ctrlKey || evt.metaKey) && evt.key === 'Enter') {
+ this.handleSubmit(evt)
+ }
+ }
+
handleSubmit = (evt) => {
evt.preventDefault()
this.setState({error: ''})
@@ -94,6 +103,7 @@ class CommentsForm extends Component {
onChange={this.handleTextChange}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
+ onKeyDown={this.handleKeyDown}
placeholder={t('comments.create.placeholder')}
maxLength='4096'
minLength='1'
diff --git a/lib/site/topic-layout/topic-article/comments/list/comment/replies/form/component.js b/lib/site/topic-layout/topic-article/comments/list/comment/replies/form/component.js
index ce0559d179..a65f98bf2e 100644
--- a/lib/site/topic-layout/topic-article/comments/list/comment/replies/form/component.js
+++ b/lib/site/topic-layout/topic-article/comments/list/comment/replies/form/component.js
@@ -47,11 +47,20 @@ class RepliesForm extends Component {
}
handleTextChange = (evt) => {
+ const text = evt.currentTarget.value || ''
+
this.setState({
- text: evt.currentTarget.value || ''
+ text: text,
+ focused: text ? true : this.state.focused
})
}
+ handleKeyDown = (evt) => {
+ if ((evt.ctrlKey || evt.metaKey) && evt.key === 'Enter') {
+ this.handleSubmit(evt)
+ }
+ }
+
handleSubmit = (evt) => {
evt.preventDefault()
this.setState({error: ''})
@@ -94,6 +103,7 @@ class RepliesForm extends Component {
onChange={this.handleTextChange}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
+ onKeyDown={this.handleKeyDown}
placeholder={t('comments.arguments.reply')}
maxLength='4096'
minLength='1'