Clicking autocomplete will return focus to text area, make the autocomplete box disappear after clicking on a name.

This commit is contained in:
Shpuld Shpuldson 2017-06-16 10:26:54 +03:00
parent b24b891c1c
commit 5dc22e9273
2 changed files with 4 additions and 1 deletions

View file

@ -77,6 +77,9 @@ const PostStatusForm = {
methods: { methods: {
replace (replacement) { replace (replacement) {
this.newStatus.status = Completion.replaceWord(this.newStatus.status, this.wordAtCaret, replacement) this.newStatus.status = Completion.replaceWord(this.newStatus.status, this.wordAtCaret, replacement)
const el = this.$el.querySelector('textarea')
el.focus()
this.caret = 0
}, },
setCaret ({target: {selectionStart}}) { setCaret ({target: {selectionStart}}) {
this.caret = selectionStart this.caret = selectionStart

View file

@ -6,7 +6,7 @@
</div> </div>
<div style="position:relative;" v-if="candidates"> <div style="position:relative;" v-if="candidates">
<div class="autocomplete-panel base05-background"> <div class="autocomplete-panel base05-background">
<div v-for="candidate in candidates" @click="replace('@' + candidate.screen_name)" class="autocomplete base01"> <div v-for="candidate in candidates" @click="replace('@' + candidate.screen_name + ' ')" class="autocomplete base01">
<img :src="candidate.img"></img> <img :src="candidate.img"></img>
<span> <span>
@{{candidate.screen_name}} @{{candidate.screen_name}}