Hi,
I recently migrated from the old TextField Formatter addon to Cleave Zen TextField Formatter (version 2.0.0 from the Vaadin Directory) while upgrading my application to Vaadin 25.
The migration itself worked fine, but I noticed a problem with ValueChangeListeners.
When I attach a NumeralFieldFormatter to a TextField, ValueChangeListeners are only triggered when using ValueChangeMode.ON_CHANGE.
With ValueChangeMode.LAZY or ValueChangeMode.EAGER, no ValueChangeEvent is fired anymore.
Minimal example:
TextField field = new TextField();
field.setValueChangeMode(ValueChangeMode.LAZY);
field.addValueChangeListener(event ->
System.out.println("Value changed: " + event.getValue()));
new NumeralFieldFormatter.Builder()
.delimiter(".")
.decimalMark(",")
.decimalScale(2)
.build()
.extend(field);
Expected behavior
- The listener should be triggered after the lazy timeout or when the field loses focus.
Actual behavior
- No
ValueChangeEventis fired at all.
Without the formatter attached, all value change modes work as expected:
| Formatter | ON_CHANGE | EAGER | LAZY |
|---|---|---|---|
| No | |||
| Yes |
Has anyone seen this before, or is there something special that needs to be configured when using ValueChangeMode.LAZY or ValueChangeMode.EAGER together with Cleave Zen Formatter?
Thanks in advance.