Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
VueJs the input value doesnt cleared with the keypress ESC the first time

I want to clear the input when i press the ESC key, the bug that i've is when i press the ESC key the first time, the input isnt cleared but when i press ESC second time it is cleard

When i display in console the value of the input after first press, it's empty but not in the UI

Here is the small piece of code that ma,age 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 need to force the first ESC press to clear this input

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

v-model uses two-way binding, so you should update context.model instead of trying to update the element value directly, as this is likely causing your problem.

i.e. assuming you have access to context.model in your function that handles the event.

Replace:

this.$refs.autocompleteInput.value = ''

with:

this.context.model = '';
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda