From 7a4af12f3f59640b4f32a0f97f36d18289d10759 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 16 Oct 2019 17:29:51 +0100 Subject: [PATCH] Focus search after add depicts should now work --- static/js/item.js | 8 +++++++- templates/item.html | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/static/js/item.js b/static/js/item.js index 927cda0..87dc6da 100644 --- a/static/js/item.js +++ b/static/js/item.js @@ -11,6 +11,9 @@ var app = new Vue({ people: people, existing_depicts: existing_depicts, }, + mounted() { + this.focus_search(); + }, methods: { remove(index) { this.$delete(this.new_depicts, index); @@ -20,11 +23,14 @@ var app = new Vue({ hit['count'] = 0; this.new_depicts.push(hit); }, + focus_search() { + this.$refs.search.focus(); + }, add_depicts(hit) { this.new_depicts.push(hit); this.hits = []; this.searchTerms = ''; - this.$refs.search.focus(); + setTimeout(this.focus_search, 500); }, run_search() { var terms = this.searchTerms; diff --git a/templates/item.html b/templates/item.html index 0ba21ea..7204c19 100644 --- a/templates/item.html +++ b/templates/item.html @@ -152,7 +152,7 @@ span.description { color: rgb(96, 96, 96); } - +