diff --git a/src/views/Search.vue b/src/views/Search.vue index b585cc6..ae36c63 100644 --- a/src/views/Search.vue +++ b/src/views/Search.vue @@ -100,9 +100,9 @@ export default { }, watch: { searching(value) { - if (value) { + if (!value) { if (this.$refs.searchTextInput) { - this.$refs.searchTextInput.focus() + this.focusSearchText() } } } @@ -111,6 +111,11 @@ export default { handleSubmit() { this.$router.push({ query: { query: this.searchText }}) this.$store.dispatch('search/search') + }, + focusSearchText() { + this.$nextTick(() => { + this.$refs.searchTextInput.focus() + }) } }, created() {