Skip to content

Commit

Permalink
fix: v-model behavior vuejs/vue#9777
Browse files Browse the repository at this point in the history
  • Loading branch information
krmax44 committed Aug 18, 2019
1 parent de4291b commit 5a3726d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/SiteSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
<label for="search" class="hidden">Search</label>

<input
v-model="query"
ref="search"
class="transition-fast relative block h-10 w-full lg:w-1/2 lg:focus:w-3/4 bg-gray-100 border border-gray-500 focus:border-blue-400 outline-none cursor-pointer text-gray-700 px-4 pb-0 pt-px"
:class="{ 'transition-border': query }"
autocomplete="off"
name="search"
placeholder="Search"
type="text"
type="search"
ref="search"
@keyup="query = $refs.search.value"
@keyup.esc="reset()"
@keyup.enter="goTo()"
/>

<button
Expand Down Expand Up @@ -94,11 +95,12 @@ export default {
})
},
reset() {
console.log('reseted')
this.query = ''
this.$refs.search.value = ''
this.searching = false
},
goTo(to) {
if (!to) to = this.results[0] && this.results[0].permalink
if (!to) return
this.$router.push(to)
this.reset()
}
Expand Down

0 comments on commit 5a3726d

Please sign in to comment.