New approach to focus search field

This commit is contained in:
Edward Betts 2019-10-16 17:19:30 +01:00
parent 61fd14427d
commit a9ef91b214
2 changed files with 2 additions and 3 deletions

View file

@ -24,8 +24,7 @@ var app = new Vue({
this.new_depicts.push(hit); this.new_depicts.push(hit);
this.hits = []; this.hits = [];
this.searchTerms = ''; this.searchTerms = '';
var search_field = document.getElementById('search-field'); this.$refs.search.focus();
search_field.focus();
}, },
run_search() { run_search() {
var terms = this.searchTerms; 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> <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" id="search-field" @input="search" /> <input class="form-control-lg my-2 w-100" autofocus autocomplete="off" v-model.trim="searchTerms" ref="search" @input="search" />
<div v-if="hits.length" id="item-list"> <div v-if="hits.length" id="item-list">
<div v-for="hit in hits"> <div v-for="hit in hits">