Focus search after add depicts should now work

This commit is contained in:
Edward Betts 2019-10-16 17:29:51 +01:00
parent a9ef91b214
commit 7a4af12f3f
2 changed files with 8 additions and 2 deletions

View file

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

View file

@ -152,7 +152,7 @@ span.description { color: rgb(96, 96, 96); }
<button type="submit" v-if="new_depicts.length" class="btn btn-primary">add these to painting on Wikidata</button>
<input class="form-control-lg my-2 w-100" autofocus autocomplete="off" v-model.trim="searchTerms" ref="search" @input="search" />
<input class="form-control-lg my-2 w-100" autocomplete="off" v-model.trim="searchTerms" ref="search" @input="search" />
<div v-if="hits.length" id="item-list">
<div v-for="hit in hits">