Merge pull request #97 from nforro/master

Fix handling newlines in messages
This commit is contained in:
gingervitis 2020-08-02 20:16:43 -07:00 committed by GitHub
commit a692904516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,6 +78,8 @@ class MessagingInterface {
this.inputChangeUserName.addEventListener('keydown', this.handleUsernameKeydown.bind(this));
this.formMessageInput.addEventListener('keydown', this.handleMessageInputKeydown.bind(this));
this.formMessageInput.addEventListener('keyup', this.handleMessageInputKeyup.bind(this));
this.formMessageInput.addEventListener('blur', this.handleMessageInputBlur.bind(this));
this.btnSubmitMessage.addEventListener('click', this.handleSubmitChatButton.bind(this));
this.initLocalStates();
@ -199,12 +201,10 @@ class MessagingInterface {
if (!this.prepNewLine) {
this.submitChat(value);
event.preventDefault();
this.prepNewLine = false;
return;
}
this.prepNewLine = false;
} else {
this.prepNewLine = false;
}
if (event.keyCode === 16 || event.keyCode === 17) { // ctrl, shift
this.prepNewLine = true;
@ -221,6 +221,16 @@ class MessagingInterface {
}
}
handleMessageInputKeyup(event) {
if (event.keyCode === 16 || event.keyCode === 17) { // ctrl, shift
this.prepNewLine = false;
}
}
handleMessageInputBlur(event) {
this.prepNewLine = false;
}
handleSubmitChatButton(event) {
var value = this.formMessageInput.value.trim();
if (value) {