This commit is contained in:
syuilo 2018-02-25 13:31:02 +09:00
parent 98339b3527
commit d94935c32d

View file

@ -152,9 +152,11 @@ class Autocomplete {
this.text = trimmedBefore + '@' + value.username + ' ' + after; this.text = trimmedBefore + '@' + value.username + ' ' + after;
// キャレットを戻す // キャレットを戻す
this.textarea.focus(); this.vm.$nextTick(() => {
const pos = caret + value.username.length; this.textarea.focus();
this.textarea.setSelectionRange(pos, pos); const pos = trimmedBefore.length + (value.username.length + 2);
this.textarea.setSelectionRange(pos, pos);
});
} else if (type == 'emoji') { } else if (type == 'emoji') {
const source = this.text; const source = this.text;
@ -166,9 +168,11 @@ class Autocomplete {
this.text = trimmedBefore + value + after; this.text = trimmedBefore + value + after;
// キャレットを戻す // キャレットを戻す
this.textarea.focus(); this.vm.$nextTick(() => {
const pos = caret + value.length; this.textarea.focus();
this.textarea.setSelectionRange(pos, pos); const pos = trimmedBefore.length + 1;
this.textarea.setSelectionRange(pos, pos);
});
} }
} }
} }