close input for reply on escape

This commit is contained in:
igoradamenko
2018-05-06 23:29:01 +03:00
parent cfe3ea5cde
commit 9bdbe6fd95
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -358,6 +358,7 @@ export default class Comment extends Component {
<Input
mix="comment__input"
onSubmit={this.onReply}
onCancel={this.toggleInputVisibility}
pid={o.id}
autoFocus
/>
+6
View File
@@ -25,9 +25,15 @@ export default class Input extends Component {
}
onKeyDown(e) {
// send on cmd+enter / ctrl+enter
if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
this.send();
}
// cancel on esc
if (e.keyCode === 27 && this.props.onCancel) {
this.props.onCancel();
}
}
autoResize() {