Skip to content

Instantly share code, notes, and snippets.

@benvp
Created July 17, 2020 13:40
Show Gist options
  • Save benvp/8ae077a93e5c6890c40bde86a3182c81 to your computer and use it in GitHub Desktop.
Save benvp/8ae077a93e5c6890c40bde86a3182c81 to your computer and use it in GitHub Desktop.
<script>
function autocomplete() {
return {
// ...
select() {
this.$refs[`item-${this.focus}`]?.click();
this.focusPrev();
},
// ...
}
}
</script>
<!--
add the following attribute to
the autocomplete container div
-->
<div x-on:keydown.enter="select()" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment