feat(message-form): send emoji at caret position

This commit is contained in:
Max Franke 2022-05-30 17:53:41 -03:00
parent e853f032be
commit 32b3d55ab8

View File

@ -271,7 +271,18 @@ class MessageForm extends PureComponent {
handleEmojiSelect(emojiObject) {
const { message } = this.state;
this.setState({ message: message + emojiObject.native });
const cursor = this.textarea.selectionStart;
this.setState(
{
message: message.slice(0, cursor)
+ emojiObject.native
+ message.slice(cursor),
},
);
const newCursor = cursor + emojiObject.native.length;
setTimeout(() => this.textarea.setSelectionRange(newCursor, newCursor), 10);
}
renderEmojiPicker() {