Merge pull request #3886 from matrix-org/t3chguy/insert_mention_colon

Fix click-to-ping not inserting colon if composer non-empty
This commit is contained in:
Michael Telatynski 2020-01-21 13:15:38 +00:00 committed by GitHub
commit ddfed32ea9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -326,7 +326,8 @@ export default class SendMessageComposer extends React.Component {
member.rawDisplayName : userId;
const caret = this._editorRef.getCaret();
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);
model.transform(() => {
const addedLen = model.insert(parts, position);