From 7ac22eb8896e2d4aedda56bfa3fbe3dff3e30ce7 Mon Sep 17 00:00:00 2001 From: Pranav Date: Mon, 5 Oct 2020 11:07:08 +0530 Subject: [PATCH] fix: prevents messages ending with spaces to exceed the msg limit --- webroot/js/components/chat/chat-input.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/webroot/js/components/chat/chat-input.js b/webroot/js/components/chat/chat-input.js index d4a21bf96..0c0ecc4d6 100644 --- a/webroot/js/components/chat/chat-input.js +++ b/webroot/js/components/chat/chat-input.js @@ -148,8 +148,7 @@ export default class ChatInput extends Component { handleMessageInputKeydown(event) { const formField = this.formMessageInput.current; - - let textValue = formField.innerText.trim(); // get this only to count chars + let textValue = formField.textContent; // get this only to count chars const newStates = {}; let numCharsLeft = CHAT_MAX_MESSAGE_LENGTH - textValue.length; const key = event && event.key; @@ -174,7 +173,7 @@ export default class ChatInput extends Component { event.preventDefault(); // value could have been changed, update char count - textValue = formField.innerText.trim(); + textValue = formField.textContent; numCharsLeft = CHAT_MAX_MESSAGE_LENGTH - textValue.length; } } @@ -193,7 +192,7 @@ export default class ChatInput extends Component { handleMessageInputKeyup(event) { const formField = this.formMessageInput.current; - const textValue = formField.innerText.trim(); // get this only to count chars + const textValue = formField.textContent; // get this only to count chars const { key } = event;