Skip to content

Commit

Permalink
fix: ensure DatePicker initializes client-side value property
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Mar 16, 2022
1 parent b476342 commit 3025f95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public class DatePicker extends GeneratedVaadinDatePicker<DatePicker, LocalDate>
*/
public DatePicker() {
this((LocalDate) null, true);
// Trigger model-to-presentation conversion in constructor, so that
// the client side component has a correct initial value of an empty
// string
this.setPresentationValue(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void datePicker_basicCases() {
DatePicker picker = new DatePicker();

Assert.assertNull(picker.getValue());
Assert.assertFalse(picker.getElement().hasProperty("value"));
Assert.assertEquals("", picker.getElement().getProperty("value"));

picker.setValue(LocalDate.of(2018, 4, 25));
Assert.assertEquals("2018-04-25",
Expand All @@ -73,7 +73,7 @@ public void datePicker_basicCases() {
public void defaultCtor_does_not_update_values() {
DatePicker picker = new DatePicker();
Assert.assertNull(picker.getValue());
Assert.assertNull(picker.getElement().getProperty("value"));
Assert.assertEquals("", picker.getElement().getProperty("value"));
}

@Test
Expand Down

0 comments on commit 3025f95

Please sign in to comment.