1

Don't work the clear method in DatePicker when inputted invalid value. I found mention of this bug in several articles https://github.com/vaadin/flow-components/issues/1696, but I can't find any solutions. I thought call "onClearButtonClick" function from js in java code. This function called when click in the clear button inside DatePicker.

2 Answers2

2

https://github.com/vaadin/flow-components/issues/2176 mentions two potential workarounds also there is new comment in the original ticket suggesting to call datePicker.getElement().executeJs("this.inputElement.value = ''") from the Java code to forcefully clear the DatePicker.

Eisenknurr
  • 374
  • 1
  • 13
0

In Vaadin 14 you can execute js to set the value to null but don't forget to dispatch the change event.

document.getElementById('yourdatepicker').value = null;
document.getElementById('yourdatepicker').dispatchEvent(new Event('change'));