edvin / tornadofx-idea-plugin

TornadoFX Plugin for IntelliJ IDEA
Apache License 2.0
72 stars 20 forks source link

ViewModel autocommit is unreliable with required #119

Closed aleferna12 closed 3 years ago

aleferna12 commented 3 years ago

When you setup a ViewModel property with autocommit == true and use the required validator on it it behaves weirdly. Lets suppose we setup a model like such:

class Person {
    val tempProperty = SimpleDoubleProperty(0.5)
}
class PersonModel(person: Person): ViewModel() {
    val temp = bind(true) { person.tempProperty }
}
// Later:
val model = PersonModel(Person())
override val root = textfield(model.temp).required()

When we erase the value from the textinput, the validator prevents the value from being commited, but the model property updates (to 0.0). Then when we type 0 into the textfield, the model doesnt detect a change and doesnt commit the model. This means the expected commit of the person value to 0.0 is skipped.

aleferna12 commented 3 years ago

Damn writing this at 5 am really wasnt a great idea, i didnt realise this wasnt the right project haha. Ill reopen this issue on the correct thread