From c3cc51dbf9604b48c33fb6890bfe5cc25b6548e5 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Fri, 24 Sep 2021 17:45:11 +0200 Subject: [PATCH] implement seach view autofocus #41 --- src/views/Search.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/views/Search.vue b/src/views/Search.vue index a5a86ad..d5b8045 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() } } } @@ -110,6 +110,11 @@ export default { methods: { handleSubmit() { this.$store.dispatch('search/search') + }, + focusSearchText() { + this.$nextTick(() => { + this.$refs.searchTextInput.focus() + }) } }, created() {