]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Fix #171: empty search opens first item v20.12.19
authorBastien Wirtz <bastien.wirtz@gmail.com>
Sat, 19 Dec 2020 23:59:01 +0000 (15:59 -0800)
committerBastien Wirtz <bastien.wirtz@gmail.com>
Sat, 19 Dec 2020 23:59:01 +0000 (15:59 -0800)
src/components/SearchInput.vue

index eb9c97860f24af0521621b2a3bdd073a2f2069a3..40c5a1de1e02981705ca763e50234c9130f34e64 100644 (file)
@@ -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')"
     />
   </div>
 </template>
@@ -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(() => {