]> source.dussan.org Git - vaadin-framework.git/commitdiff
Removing code causing the trouble (#11898) pr11907/r7
authorTatu Lund <tatu@vaadin.com>
Mon, 24 Feb 2020 10:51:20 +0000 (12:51 +0200)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2020 10:51:20 +0000 (12:51 +0200)
* Removing code causing the  trouble

Removing code that was apparently not needed in previous fix and caused regression

Fixes: https://github.com/vaadin/framework/issues/11895
* Added feature to test UI

* Added test case

* Adding missing import

* Fixing test UI

* Enable DateField

client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChange.java
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChangeTest.java

index 765df8867d3f0e720ca18a1f5d62ed4f7760a9d4..ff60fe154dbd099959c63f348defdb480fcaf712 100644 (file)
@@ -975,10 +975,6 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>>
     public void renderCalendar(boolean updateDate) {
         if (parent instanceof VAbstractPopupCalendar
                 && !((VAbstractPopupCalendar) parent).popup.isShowing()) {
-            if (getDate() == null) {
-                // no date set, cannot pre-render yet
-                return;
-            }
             // a popup that isn't open cannot possibly need a focus change event
             updateDate = false;
         }
index 55b2823a1d168f1802ab3b9c00425b7f154619e8..62ecb8428c1c3665cdccca2b18d9fd4268b398ff 100644 (file)
@@ -30,9 +30,16 @@ public class DateFieldMonthResolutionStatusChange extends AbstractTestUI {
             dateField.setRangeEnd(LocalDate.of(2020, 1, 1));
         });
 
+        Button resetValueButton = new Button("Reset value");
+        resetValueButton.setId("resetValue");
+        resetValueButton.addClickListener(event -> {
+            dateField.setValue(LocalDate.now());
+        });
+
         addComponent(dateField);
         addComponent(dateReadOnlySwitch);
         addComponent(addRangeButton);
+        addComponent(resetValueButton);
     }
 
     @Override
index 58a926546cb6f0271a8533e6ecf9c62bb6eaecc3..0473a582e8dafac73eb3763f459a8c274e12a751 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.tests.components.datefield;
 import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
+import org.openqa.selenium.By;
 
 import com.vaadin.testbench.elements.ButtonElement;
 import com.vaadin.testbench.elements.DateFieldElement;
@@ -35,4 +36,22 @@ public class DateFieldMonthResolutionStatusChangeTest
         assertEquals("Unexpected date change.", "1/19", df.getValue());
     }
 
+    @Test
+    public void testPopupOpenWithDateNotInRange() {
+        openTestURL();
+        DateFieldElement df = $(DateFieldElement.class).first();
+
+        // switch read-only state
+        $(ButtonElement.class).id("readOnly").click();
+        // set value before range
+        $(ButtonElement.class).id("resetValue").click();
+        // add range, previously set date is not in range
+        $(ButtonElement.class).id("addRange").click();
+
+        // Test that popup still opens
+        df.openPopup();
+        waitForElementPresent(By.className("v-datefield-popup"));
+        assertElementPresent(By.className("v-datefield-popup"));
+    }
+
 }