mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-01 18:06:45 +01:00
refs #352 Close suggest popover when text is not match
This commit is contained in:
parent
d4d3514990
commit
bdfd0beb29
@ -82,16 +82,23 @@ export default {
|
||||
// e.target.value: current value of the textarea
|
||||
const [start, word] = suggestText(e.target.value, e.target.selectionStart, '@')
|
||||
if (!start || !word) {
|
||||
this.closeSuggest()
|
||||
return false
|
||||
}
|
||||
this.filteredAccounts = this.accounts.filter((a) => a.startsWith(word))
|
||||
if (this.filteredAccounts.length === 0) {
|
||||
this.closeSuggest()
|
||||
return false
|
||||
}
|
||||
this.openSuggest = true
|
||||
this.startIndex = start
|
||||
this.matchWord = word
|
||||
},
|
||||
closeSuggest () {
|
||||
this.openSuggest = false
|
||||
this.startIndex = null
|
||||
this.matchWord = null
|
||||
},
|
||||
suggestHighlight (index) {
|
||||
if (index < 0) {
|
||||
this.highlightedIndex = 0
|
||||
@ -102,7 +109,6 @@ export default {
|
||||
}
|
||||
},
|
||||
insertAccount (account) {
|
||||
console.log(account)
|
||||
const str = `${this.status.slice(0, this.startIndex - 1)}${account} ${this.status.slice(this.startIndex + this.matchWord.length)}`
|
||||
this.status = str
|
||||
this.openSuggest = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user