diff --git a/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/main/java/com/vaadin/flow/component/datepicker/DatePicker.java b/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/main/java/com/vaadin/flow/component/datepicker/DatePicker.java index cbdb002d558..72cb49eead5 100644 --- a/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/main/java/com/vaadin/flow/component/datepicker/DatePicker.java +++ b/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/main/java/com/vaadin/flow/component/datepicker/DatePicker.java @@ -83,6 +83,10 @@ public class DatePicker extends GeneratedVaadinDatePicker */ 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); } /** diff --git a/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/test/java/com/vaadin/flow/component/datepicker/DatePickerTest.java b/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/test/java/com/vaadin/flow/component/datepicker/DatePickerTest.java index 55847081ad8..60fed87c727 100644 --- a/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/test/java/com/vaadin/flow/component/datepicker/DatePickerTest.java +++ b/vaadin-date-picker-flow-parent/vaadin-date-picker-flow/src/test/java/com/vaadin/flow/component/datepicker/DatePickerTest.java @@ -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", @@ -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