Vue: First letter disapears with textarea v-model.lazy and @input

Created on 24 Jul 2017  路  3Comments  路  Source: vuejs/vue

Version

2.4.2

Reproduction link

https://jsfiddle.net/kessiacastro/gn9w320q/

Steps to reproduce

When anything is typed in a textarea with v-model.lazy and @input event checking the e.target.value the first letter typed disapears of the textarea. It also happens when using @keydown event.

What is expected?

The typed message should appear normally in the textarea.

What is actually happening?

Only the first letter disappears in the text area.

Most helpful comment

Closing because it's working as expected, it's an edge case though
You can workaround by putting the texarea into a component: https://jsfiddle.net/5nfqd4e8/

All 3 comments

It's more like an expected behavior and that's how .lazy works: the change event will only fire when textarea loses focus.

More specific in your repro code: when type in any character, input event fired, and this.disableButton = e.target.value === '' get executed and which caused a re-render. In that re-render, vue does render value of message into textarea, which is still empty till then because change event never fired during this process.

~It looks like the template compilation is adding too many things.~

edit: ~I think~ @jkzing is right, it's happening because of the re render...

Closing because it's working as expected, it's an edge case though
You can workaround by putting the texarea into a component: https://jsfiddle.net/5nfqd4e8/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julianxhokaxhiu picture julianxhokaxhiu  路  3Comments

fergaldoyle picture fergaldoyle  路  3Comments

paceband picture paceband  路  3Comments

paulpflug picture paulpflug  路  3Comments

loki0609 picture loki0609  路  3Comments