trivago / melody

Melody is a library for building JavaScript web applications.
https://melody.js.org
Apache License 2.0
215 stars 39 forks source link

Input element value goes out of sync from component state field it's bound to #158

Open mnegulescu opened 4 years ago

mnegulescu commented 4 years ago

Explain the problem When the state field bound to an input is updated the second time to the same value, the value of the input element goes out of sync with the component state, seems like a caching issue. It seems that the first update of the field is reflected by the input's value, but the second time, as the field is updated to the same value, the DOM is not updated any more.

Expected Behaviour The value of the input element should be updated every time the state is updated, and should not go out of sync from the component state.

Actual Behaviour The second time the state is emitted with the same value for the input, the value of the input element does not change, and no longer reflects the value bound to it.

Steps to reproduce Create a component where a field of the component state is bound to the value of an input element. Add logic that limits the number of the field (validation), which sets a predefined max or min number of the number manually set is out of bounds. Manually set a number lower or higher than allowed, so the state logic emits the same max or min number consecutively. The second time the same state value is emitted for that input, it will go out of sync.