输入无效值时,不要在 DatePicker 中使用 clear 方法

Don't work the clear method in DatePicker when inputted invalid value

当输入无效值时,不使用 DatePicker 中的清除方法。 我在几篇文章 https://github.com/vaadin/flow-components/issues/1696 中发现了这个错误,但我找不到任何解决方案。 我想在 java 代码中从 js 调用“onClearButtonClick”函数。单击 DatePicker 中的清除按钮时调用此函数。

https://github.com/vaadin/flow-components/issues/2176 mentions two potential workarounds also there is new comment 原工单中建议调用 datePicker.getElement().executeJs("this.inputElement.value = ''") 从 Java 代码强制清除 DatePicker。