From 274802e0b0f733fe4fb6b0345dedabe3f3939383 Mon Sep 17 00:00:00 2001 From: Anastasia Smirnova Date: Wed, 17 Oct 2018 11:12:03 +0300 Subject: Rebuild calendar pop-up on readOnly state change (#11249) * Rebuild calendar pop-up on readOnly state change Fixes https://github.com/vaadin/framework/issues/6565 --- .../vaadin/client/ui/VAbstractCalendarPanel.java | 9 ++++++ .../client/ui/datefield/TextualDateConnector.java | 6 +++- .../datefield/DateTimeFieldAfterReadOnly.java | 37 ++++++++++++++++++++++ .../datefield/DateTimeFieldAfterReadOnlyTest.java | 33 +++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnly.java create mode 100644 uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java index 8a3c6c3325..655f18669c 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java @@ -938,6 +938,15 @@ public abstract class VAbstractCalendarPanel> renderCalendar(true); } + /** + * Returns the value of initialRenderDone + * + * @since + */ + public boolean isInitialRenderDone() { + return initialRenderDone; + } + /** * For internal use only. May be removed or replaced in the future. * diff --git a/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java b/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java index f29a053c56..c254833d18 100644 --- a/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/datefield/TextualDateConnector.java @@ -117,7 +117,7 @@ public abstract class TextualDateConnector { + timeField.setReadOnly(!timeField.isReadOnly()); + }); + b.setId("readOnlySwitch"); + + addComponent(b); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java new file mode 100644 index 0000000000..6e2f748015 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java @@ -0,0 +1,33 @@ +package com.vaadin.tests.components.datefield; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.AbstractDateFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; + +import static junit.framework.TestCase.assertEquals; + +public class DateTimeFieldAfterReadOnlyTest extends MultiBrowserTest { + + @Test + public void readOnlyDateFieldPopupShouldNotOpen() { + openTestURL(); + toggleReadOnly(); + openPopup(); + assertEquals(2, numberOfSelectsField()); + } + + private void openPopup() { + $(AbstractDateFieldElement.class).first() + .findElement(By.tagName("button")).click(); + } + + private void toggleReadOnly() { + findElement(By.id("readOnlySwitch")).click(); + } + + private int numberOfSelectsField() { + return findElement(By.className("v-datefield-calendarpanel-time")) + .findElements(By.className("v-select")).size(); + } +} -- cgit v1.2.3