hide results on outside click

This commit is contained in:
taehoon 2019-04-02 13:18:36 -04:00
parent 6d3187b449
commit 787737c80d
5 changed files with 21 additions and 4 deletions

View file

@ -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
}
}
}