aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_autosuggest
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/user_autosuggest')
-rw-r--r--src/components/user_autosuggest/user_autosuggest.js14
-rw-r--r--src/components/user_autosuggest/user_autosuggest.vue4
2 files changed, 14 insertions, 4 deletions
diff --git a/src/components/user_autosuggest/user_autosuggest.js b/src/components/user_autosuggest/user_autosuggest.js
index eff6ef75..b99f61cc 100644
--- a/src/components/user_autosuggest/user_autosuggest.js
+++ b/src/components/user_autosuggest/user_autosuggest.js
@@ -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
}
}
}
diff --git a/src/components/user_autosuggest/user_autosuggest.vue b/src/components/user_autosuggest/user_autosuggest.vue
index 743d9eaf..eb5aa41b 100644
--- a/src/components/user_autosuggest/user_autosuggest.vue
+++ b/src/components/user_autosuggest/user_autosuggest.vue
@@ -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>