Fix index for _insertMention

pull/21833/head
Michael Telatynski 2020-01-21 11:13:08 +00:00
parent 8b2adf313f
commit f56a9d246f
1 changed files with 2 additions and 1 deletions

View File

@ -326,7 +326,8 @@ export default class SendMessageComposer extends React.Component {
member.rawDisplayName : userId; member.rawDisplayName : userId;
const caret = this._editorRef.getCaret(); const caret = this._editorRef.getCaret();
const position = model.positionForOffset(caret.offset, caret.atNodeEnd); const position = model.positionForOffset(caret.offset, caret.atNodeEnd);
const insertIndex = position.index + 1; // index is -1 if there are no parts but we only care for if this would be the part in position 0
const insertIndex = position.index > 0 ? position.index : 0;
const parts = partCreator.createMentionParts(insertIndex, displayName, userId); const parts = partCreator.createMentionParts(insertIndex, displayName, userId);
model.transform(() => { model.transform(() => {
const addedLen = model.insert(parts, position); const addedLen = model.insert(parts, position);