From: Bastien Wirtz Date: Sat, 19 Dec 2020 23:59:01 +0000 (-0800) Subject: Fix #171: empty search opens first item X-Git-Tag: v20.12.19^0 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;ds=inline;h=c1b5f6adabf6bdd35a6b562f796ffbefa77f7cbc;hp=168810d76f7d4ad929737fedf18dd8d9decb4d89;p=github%2Fbastienwirtz%2Fhomer.git Fix #171: empty search opens first item --- diff --git a/src/components/SearchInput.vue b/src/components/SearchInput.vue index eb9c978..40c5a1d 100644 --- a/src/components/SearchInput.vue +++ b/src/components/SearchInput.vue @@ -6,8 +6,8 @@ ref="search" :value="value" @input="search($event.target.value)" - @keyup.enter.exact="$emit('search-open')" - @keyup.alt.enter="$emit('search-open', '_blank')" + @keyup.enter.exact="open()" + @keyup.alt.enter="open('_blank')" /> @@ -37,6 +37,12 @@ export default { } }, methods: { + open: function (target = null) { + if (!this.$refs.search.value) { + return; + } + this.$emit("search-open", target); + }, focus: function () { this.$emit("search-focus"); this.$nextTick(() => {