mirror of
https://github.com/vector-im/element-web.git
synced 2024-12-02 17:36:44 +08:00
Fix inserting trailing colon after mention/pill
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
cd39474d26
commit
c2b66d0dbe
@ -502,9 +502,10 @@ export default class SendMessageComposer extends React.Component {
|
||||
member.rawDisplayName : userId;
|
||||
const caret = this._editorRef.getCaret();
|
||||
const position = model.positionForOffset(caret.offset, caret.atNodeEnd);
|
||||
// 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);
|
||||
// createMentionParts() assumes that the mention already has it's own part
|
||||
// which isn't true, therefore we increase the position.index by 1. This
|
||||
// also solves the problem of the index being -1 when the composer is empty.
|
||||
const parts = partCreator.createMentionParts(position.index + 1, displayName, userId);
|
||||
model.transform(() => {
|
||||
const addedLen = model.insert(parts, position);
|
||||
return model.positionForOffset(caret.offset + addedLen, true);
|
||||
|
Loading…
Reference in New Issue
Block a user