aboutsummaryrefslogtreecommitdiff
path: root/vnext
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-20 16:44:21 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:52 +0300
commit889f5564332de78c982ac1bb4f9964f393482449 (patch)
tree4a1a1404cf6464dcd1aafa87c334d9b341171358 /vnext
parent504c080d8fa091682dd9f6a5bbc261375ca03861 (diff)
handle ctrl-enter
Diffstat (limited to 'vnext')
-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>