share user pill postfix between autocomplete and insert mention
where we decide to add a colon only if the composer is empty
This commit is contained in:
parent
c219f925c6
commit
c595371845
3 changed files with 10 additions and 5 deletions
|
@ -290,11 +290,12 @@ export default class SendMessageComposer extends React.Component {
|
|||
const member = this.props.room.getMember(userId);
|
||||
const displayName = member ?
|
||||
member.rawDisplayName : userId;
|
||||
const userPillPart = partCreator.userPill(displayName, userId);
|
||||
const caret = this._editorRef.getCaret();
|
||||
const position = model.positionForOffset(caret.offset, caret.atNodeEnd);
|
||||
const insertIndex = position.index + 1;
|
||||
const parts = partCreator.createMentionParts(insertIndex, displayName, userId);
|
||||
model.transform(() => {
|
||||
const addedLen = model.insert([userPillPart], position);
|
||||
const addedLen = model.insert(parts, position);
|
||||
return model.positionForOffset(caret.offset + addedLen, true);
|
||||
});
|
||||
// refocus on composer, as we just clicked "Mention"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue