site: decouple state from event handlers
Try to avoid directly setting state from event handlers and instead provide utility functions that mutate state in a consistent way.
This commit is contained in:
parent
b1cd0dad8d
commit
8168bb9715
2 changed files with 42 additions and 29 deletions
|
@ -11,16 +11,16 @@
|
|||
x-ref="tags"
|
||||
@focus="fetchSuggestions"
|
||||
@input.debounce="fetchSuggestions"
|
||||
@keydown.tab="completeSuggestion"
|
||||
@keydown.up.prevent="setCurrentSuggestion($event, -1)"
|
||||
@keydown.down.prevent="setCurrentSuggestion($event, +1)"
|
||||
@keydown.tab.prevent="completeSuggestion"
|
||||
@keydown.up.prevent="previousSuggestion"
|
||||
@keydown.down.prevent="nextSuggestion"
|
||||
@keydown.escape="reset">
|
||||
<ul id="tags-suggestions"
|
||||
x-cloak x-show="suggestions.length > 0">
|
||||
<template x-for="suggestion in suggestions">
|
||||
<li
|
||||
@click="selectCurrentSuggestion"
|
||||
@mouseenter="setCurrentSuggestion">
|
||||
@click="completeClickedSuggestion"
|
||||
@mouseenter="setPointerSuggestion">
|
||||
<span
|
||||
x-text="suggestion.display"
|
||||
:class="suggestion.kind_class">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue