ComponentError is not showing in DateField

I have 3 elements in a HorizontalLayout:

[code]
protected TextField relCode = new TextField(“Rel”);
protected DateField startDate = new DateField(“Start”);
protected DateField endDate = new DateField(“End”);

endDate.addValueChangeListener( e → validateEndDate(e.getValue()));

private void validateEndDate(LocalDate value) {
if (value.isBefore(startDate.getValue()))) {
UserError error = new UserError(“End date cannot be < than Start date”);
endDate.setComponentError(error);
relCode.setComponentError(error);
} else {
endDate.setComponentError(null);
relCode.setComponentError(null);
}
}
[/code]If i put in EndDate a date lower than StartDate, the message error is showing only in relCode textField and not in the endDate textField.

Hi,
it seems that the problem is in AbstractDateField.changeVariables; there is a call to setValue followed by a
setComponentError(null).

This may be a bug in the framework

BTW, if you simply want to restrict date selection you could do something like

startDate.addValueChangeListener(e -> endDate.setRangeStart(e.getValue()));
endDate.addValueChangeListener(e -> startDate.setRangeEnd(e.getValue()));

HTH
Marco

Hi,
I’ve opened an issue on github

https://github.com/vaadin/framework/issues/10011

Thank you Marco.
I was thinking was a bug, but it seemed strange that nobody had this issue before.