summaryrefslogtreecommitdiffstats
path: root/uitest/src/main
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2021-02-19 11:11:49 +0200
committerGitHub <noreply@github.com>2021-02-19 11:11:49 +0200
commit551177326f6ae8c4ddd7d5b3ab3bb3311304cc0a (patch)
tree9f370578832547243f8f516b7f2b30ce79fb1194 /uitest/src/main
parent45ed0c173aedb8c0b7194ed0b8eb656d24ddac9d (diff)
downloadvaadin-framework-551177326f6ae8c4ddd7d5b3ab3bb3311304cc0a.tar.gz
vaadin-framework-551177326f6ae8c4ddd7d5b3ab3bb3311304cc0a.zip
Add API to prevent invalid input when integrated range validator is used (#12168)
Do not fire DateField's value change event if the new date is not within the range. Fixes: #12163
Diffstat (limited to 'uitest/src/main')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPreventInvalidInput.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPreventInvalidInput.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPreventInvalidInput.java
new file mode 100644
index 0000000000..257feefb6b
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPreventInvalidInput.java
@@ -0,0 +1,32 @@
+package com.vaadin.tests.components.datefield;
+
+import java.time.LocalDate;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.Label;
+
+public class DateFieldPreventInvalidInput extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ DateField dateField = new DateField();
+ dateField.setRangeStart(LocalDate.ofYearDay(2019, 1));
+ dateField.setRangeEnd(LocalDate.ofYearDay(2019, 365));
+ dateField.setPreventInvalidInput(true);
+ Button button = new Button("", event -> {
+ dateField.clear();
+ dateField.setPreventInvalidInput(false);
+ });
+ Label value = new Label();
+ value.setValue("no-value");
+ value.setId("value");
+ dateField.addValueChangeListener(event -> {
+ value.setValue(dateField.getValue().toString());
+ });
+ addComponents(dateField,value,button);
+ }
+
+}