hide results on outside click
This commit is contained in:
parent
6d3187b449
commit
787737c80d
5 changed files with 21 additions and 4 deletions
|
@ -11,7 +11,8 @@ export default {
|
|||
return {
|
||||
query: '',
|
||||
results: [],
|
||||
timeout: null
|
||||
timeout: null,
|
||||
resultsVisible: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -26,9 +27,18 @@ export default {
|
|||
this.results = []
|
||||
if (query) {
|
||||
userSearchApi.search({query, store: this.$store})
|
||||
.then((data) => { this.results = data })
|
||||
.then((data) => {
|
||||
this.results = data
|
||||
this.resultsVisible = true
|
||||
})
|
||||
}
|
||||
}, debounceMilliseconds)
|
||||
},
|
||||
onInputClick () {
|
||||
this.resultsVisible = true
|
||||
},
|
||||
onClickOutside () {
|
||||
this.resultsVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="user-autosuggest">
|
||||
<input v-model="query" placeholder="Search..." />
|
||||
<div class="user-autosuggest-results">
|
||||
<div class="user-autosuggest" v-click-outside="onClickOutside">
|
||||
<div class="user-autosuggest-results" v-if="resultsVisible">
|
||||
<BasicUserCard v-for="user in results" :key="user.id" :user="user"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -22,6 +22,7 @@ import pushNotifications from './lib/push_notifications_plugin.js'
|
|||
import messages from './i18n/messages.js'
|
||||
|
||||
import VueChatScroll from 'vue-chat-scroll'
|
||||
import VueClickOutside from 'v-click-outside'
|
||||
|
||||
import afterStoreSetup from './boot/after_store.js'
|
||||
|
||||
|
@ -39,6 +40,7 @@ Vue.use(VueTimeago, {
|
|||
})
|
||||
Vue.use(VueI18n)
|
||||
Vue.use(VueChatScroll)
|
||||
Vue.use(VueClickOutside)
|
||||
|
||||
const i18n = new VueI18n({
|
||||
// By default, use the browser locale, we will update it if neccessary
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue