Closed hfazai closed 2 years ago
It is: https://github.com/mvysny/karibu-testing/tree/master/karibu-testing-v10#changing-values
Simply use the textField._fireValueChange()
function.
Hi Martin,
Thanks for the answer!
the textField._fireValueChange()
actually works fine. But I should call it just after textField.value = "value"
, right?
In this case the listener is called twice as _value
also fires the value change event. This can lead sometimes to wrong behaviour.
That is true. Unfortunately, no component provides direct means of setting the value and pretending it was from a client. In theory I could access the fieldSupport
private field and try to call setValue(value, false, true)
but that could backfire seriously if the setValue() would not use fieldSupport
for some reason (or use it differently, e.g. CustomField).
The cleanest approach I could figure out is to set the _value
first, then _fireValueChange()
and suffer that the event listener has been called two times :( However, please let me know if you have a better idea :+1:
Closing as won't fix since we failed to come up with a better solution, but please feel free to reopen&post a better solution if you find one :+1:
Hi @mvysny ,
Definitively, if I find an other solution I will post it.
I thought of finding a way to set the value without triggering a value change event.
Is there any way to get all registred valuechange listeners on a field? So we can remove them using Registration.remove()
, set the value and then re-resigter all those listeners.
Hi,
field._value = ".."
sets the value of a field and then fires a value change event where "event.isFromClient = false".Is it possible to simulate a value change from client?