When I press the ESC key, my input should clear. However, I am experiencing a bug where the input is not cleared after the first press of the ESC key; it only clears after the second press.
Even though the console displays an empty value for the input after the first press, it remains unchanged in the UI.
Below is a snippet of code that handles the ESC key:
HTML :
<input
type="text"
:name="context.name"
:id="context.id"
v-model="context.model"
@blur="context.blurHandler"
@keyup="getSuggestions"
autocomplete="no"
class="mc-text-input"
ref="autocompleteInput"
/>
And the ESC event:
case 27: {
console.log('Before : ' + this.$refs.autocompleteInput.value)
this.$refs.autocompleteInput.value = ''
console.log('After : ' + this.$refs.autocompleteInput.value)
this.resetAutocompleteElt() // hide the autocomplete list
break
}
I am looking for a way to ensure that the input is cleared on the first press of the ESC key.