Fix #171: empty search opens first item

This commit is contained in:
Bastien Wirtz 2020-12-19 15:59:01 -08:00
parent 168810d76f
commit c1b5f6adab

View File

@ -6,8 +6,8 @@
ref="search" ref="search"
:value="value" :value="value"
@input="search($event.target.value)" @input="search($event.target.value)"
@keyup.enter.exact="$emit('search-open')" @keyup.enter.exact="open()"
@keyup.alt.enter="$emit('search-open', '_blank')" @keyup.alt.enter="open('_blank')"
/> />
</div> </div>
</template> </template>
@ -37,6 +37,12 @@ export default {
} }
}, },
methods: { methods: {
open: function (target = null) {
if (!this.$refs.search.value) {
return;
}
this.$emit("search-open", target);
},
focus: function () { focus: function () {
this.$emit("search-focus"); this.$emit("search-focus");
this.$nextTick(() => { this.$nextTick(() => {