From 7526b5305c02461927655bab023165985a239d45 Mon Sep 17 00:00:00 2001 From: Meisam <39205857+MFTabriz@users.noreply.github.com> Date: Sat, 24 Jul 2021 19:25:40 +0200 Subject: [PATCH] add emoji to the caret position (#1253) --- webroot/js/components/chat/chat-input.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webroot/js/components/chat/chat-input.js b/webroot/js/components/chat/chat-input.js index 89952333b..258708562 100644 --- a/webroot/js/components/chat/chat-input.js +++ b/webroot/js/components/chat/chat-input.js @@ -123,10 +123,14 @@ export default class ChatInput extends Component { content = emoji.emoji; } - const newHTML = inputHTML + content; + const position = getCaretPosition(this.formMessageInput.current); + const newHTML = inputHTML.substring(0, position) + + content + + inputHTML.substring(position); + const charsLeft = this.calculateCurrentBytesLeft(newHTML); this.setState({ - inputHTML: inputHTML + content, + inputHTML: newHTML, inputCharsLeft: charsLeft, }); // a hacky way add focus back into input field