DateTimeField and Binder causing status change

Hello guys.

We have two field on form. One is combobox and one is DateTimeField. The data is bind with binder and we use readBean method.
Also we use this method: binder.bindInstanceFields(this) to bind our fields to entity data (same name as properties in entity).
The form itself has 74 lines of code including import lines. Very simple form. Check attachments for visual presentation of the form.
Green button is save, and the white one is cancel button.

The binder listener for tracking user changes:

 binder = new BeanValidationBinder<>(entityType);
        binder.addValueChangeListener(e -> {
            if (!settingBean) {
                hasChanges = true;
            }
        });

        binder.addStatusChangeListener(e -> {
            if (!settingBean) {
                hasChanges = true;
            }
            adjustResetButtonState();
            adjustSaveButtonState();
        });

Problem:

  • When DateTimeField is binded with binder, the binder invoke listeners above event without user changing the data on form. Then on cancel button (because of fake changes) the user is prompt for losing the data.
  • When we remove DateTimeField from form (no binding), the listeners work as expected (doesnt get invoked on cancel action). The prompt for changes does not shown because there was no changes on data.

We tested on 8.12.0, 8.12.1, 8.12.2.

Any idea what is wrong ? Maybe something internal changes in binder in recent versions ?

Thanks.

18520665.png

Hi,

That might be related to this issue: https://github.com/vaadin/framework/issues/12054

Basically the datetimepicker truncates your datetime (so the datetime is changed).

Thanks for your answer. You are a life saver.

We could override the part of DateTimeField where truncate data base of DateResolution setting in field and make our own component.

This should be documented somewhere or something. Major issue probably for a lot of people.

But i guess if you show only minutes, the data behind it also have only minutes and seconds are 00. Not in our case though.

Thanks again.