aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/MessageInput.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/components/MessageInput.js')
-rw-r--r--vnext/src/components/MessageInput.js12
1 files changed, 9 insertions, 3 deletions
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} />
</div>
- <textarea name="body" onChange={this.textChanged}
+ <textarea name="body" onChange={this.textChanged} onKeyPress={this.handleCtrlEnter}
ref={this.textarea} style={textInputStyle} value={this.state.value}
rows="1" placeholder="Write a comment..." />
<button className="badge" onClick={this.onSubmit}>Send</button>