Skip to content

[DatePicker] Sequential programmatic value changes are ignored by input element #7250

Closed
@glebfox

Description

@glebfox

Description

If a DatePicker has a value and then we programmatically change it to null and not-null in a single call, then server-side contains a value, but the field displays none.

Expected outcome

Nested Input element value is synced with DatePicker

Minimal reproducible example

VerticalLayout log = new VerticalLayout();
HorizontalLayout fieldWrapper = new HorizontalLayout();

DatePicker datePicker = new DatePicker();
datePicker.setValue(LocalDate.now());   // set default value
datePicker.addValueChangeListener(e -> {
    log.add(new Div(String.valueOf(e.getValue())));
});

Button setValueBtn = new Button("Set Value", __ -> {
    // clear and set value again
    datePicker.setValue(null);
    datePicker.setValue(LocalDate.now());
});

Button getValueBtn = new Button("Get Value", __ ->
        Notification.show("Value: " + datePicker.getValue(), 3000, Notification.Position.MIDDLE));

fieldWrapper.add(datePicker, setValueBtn, getValueBtn);

add(fieldWrapper, log);

Steps to reproduce

  1. Add a snippet above to a view
  2. Click Set Value

AR:

Field "thinks" that it has a value but displays none

Image

Environment

Vaadin version(s): 24.6.3, 24.6.7, 24.7.0
OS: macOS 15.3.2

Browsers

Chrome

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions