summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-03-28 22:03:55 +0200
committerArtur Signell <artur@vaadin.com>2014-03-31 19:19:09 +0000
commitd0bc54ba4b487fe461cc950de02ec57187c654ad (patch)
tree7e8ca5b152907cc625307b1bb604f6496748f025
parent7a47febb2fdb03a743cca60409426ff70cc463a2 (diff)
downloadvaadin-framework-d0bc54ba4b487fe461cc950de02ec57187c654ad.tar.gz
vaadin-framework-d0bc54ba4b487fe461cc950de02ec57187c654ad.zip
Prevent popup open when datafield is disabled (#13508).
Change-Id: I5bb3ec24ad15d832a43998a4cee49a61ae81562e
-rw-r--r--WebContent/VAADIN/themes/base/datefield/datefield.scss3
-rw-r--r--client/src/com/vaadin/client/ui/VPopupCalendar.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopup.java46
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java52
4 files changed, 101 insertions, 2 deletions
diff --git a/WebContent/VAADIN/themes/base/datefield/datefield.scss b/WebContent/VAADIN/themes/base/datefield/datefield.scss
index cbba9b46f3..d094235c0f 100644
--- a/WebContent/VAADIN/themes/base/datefield/datefield.scss
+++ b/WebContent/VAADIN/themes/base/datefield/datefield.scss
@@ -56,7 +56,8 @@
border: 1px solid #ddd;
}
.v-disabled .#{$primaryStyleName}-calendarpanel-day,
-.v-disabled .#{$primaryStyleName}-calendarpanel-day-today {
+.v-disabled .#{$primaryStyleName}-calendarpanel-day-today,
+.v-disabled.#{$primaryStyleName}-popupcalendar .#{$primaryStyleName}-button {
cursor: default;
}
.#{$primaryStyleName}-calendarpanel-day-disabled,
diff --git a/client/src/com/vaadin/client/ui/VPopupCalendar.java b/client/src/com/vaadin/client/ui/VPopupCalendar.java
index d2c9b7160c..e2ad40c929 100644
--- a/client/src/com/vaadin/client/ui/VPopupCalendar.java
+++ b/client/src/com/vaadin/client/ui/VPopupCalendar.java
@@ -329,7 +329,7 @@ public class VPopupCalendar extends VTextualDate implements Field,
*/
public void openCalendarPanel() {
- if (!open && !readonly) {
+ if (!open && !readonly && isEnabled()) {
open = true;
if (getCurrentDate() != null) {
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopup.java b/uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopup.java
new file mode 100644
index 0000000000..c48d2383a7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopup.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.DateField;
+
+/**
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+public class DisabledDateFieldPopup extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ DateField field = new DateField();
+ field.setEnabled(false);
+ addComponent(field);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Don't open popup calendar if datefield is disabled";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 13508;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java b/uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java
new file mode 100644
index 0000000000..dc287c19da
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.datefield;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+public class DisabledDateFieldPopupTest extends MultiBrowserTest {
+
+ @Test
+ public void testPopup() {
+ openTestURL();
+
+ WebElement button = driver.findElement(By
+ .className("v-datefield-button"));
+ button.click();
+
+ Assert.assertFalse(
+ "Calendar popup should not be opened for disabled date field on mouse click",
+ isElementPresent(By.className("v-datefield-popup")));
+
+ button.sendKeys(Keys.ARROW_DOWN);
+
+ Assert.assertFalse("Calendar popup should not be opened for "
+ + "disabled date fild on down key",
+ isElementPresent(By.className("v-datefield-popup")));
+
+ }
+}