From 889f5564332de78c982ac1bb4f9964f393482449 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Wed, 20 Jun 2018 16:44:21 +0300
Subject: handle ctrl-enter
---
vnext/src/components/MessageInput.js | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
(limited to 'vnext')
diff --git a/vnext/src/components/MessageInput.js b/vnext/src/components/MessageInput.js
index 30c411fd..57ee8f3c 100644
--- a/vnext/src/components/MessageInput.js
+++ b/vnext/src/components/MessageInput.js
@@ -11,7 +11,7 @@ export default class MessageInput extends React.Component {
this.textChanged = this.textChanged.bind(this);
this.attachmentChanged = this.attachmentChanged.bind(this);
this.openfile = this.openfile.bind(this);
-
+ this.handleCtrlEnter = this.handleCtrlEnter.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.textarea = React.createRef();
@@ -25,8 +25,14 @@ export default class MessageInput extends React.Component {
}
}
+ handleCtrlEnter(event) {
+ if (event.ctrlKey && (event.charCode == 10 || event.charCode == 13)) {
+ this.onSubmit({})
+ }
+ }
+
onSubmit(event) {
- event.preventDefault();
+ if (event.preventDefault) event.preventDefault();
const input = this.fileinput.current;
this.props.onSend({
mid: this.state.mid,
@@ -75,7 +81,7 @@ export default class MessageInput extends React.Component {
style={{ display: 'none' }} ref={this.fileinput} value={this.state.attach}
onChange={this.attachmentChanged} />
-
--
cgit v1.2.3