Browse Source

add emoji to the caret position (#1253)

pull/1262/head
Meisam 4 years ago committed by GitHub
parent
commit
7526b5305c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      webroot/js/components/chat/chat-input.js

8
webroot/js/components/chat/chat-input.js

@ -123,10 +123,14 @@ export default class ChatInput extends Component { @@ -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

Loading…
Cancel
Save