aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ui/VPopupCalendar.java38
-rw-r--r--client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStates.java57
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java19
4 files changed, 112 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/ui/VPopupCalendar.java b/client/src/com/vaadin/client/ui/VPopupCalendar.java
index 1474ad3b71..577e267d3b 100644
--- a/client/src/com/vaadin/client/ui/VPopupCalendar.java
+++ b/client/src/com/vaadin/client/ui/VPopupCalendar.java
@@ -240,7 +240,23 @@ public class VPopupCalendar extends VTextualDate implements Field,
*/
public void setTextFieldEnabled(boolean textFieldEnabled) {
this.textFieldEnabled = textFieldEnabled;
- text.setEnabled(textFieldEnabled);
+ // IE has a non input disabled themeing that can not be overridden so we
+ // must fake the functionality using readonly and unselectable
+ if (BrowserInfo.get().isIE()) {
+ if (!textFieldEnabled) {
+ text.getElement().setAttribute("unselectable", "on");
+ text.getElement().setAttribute("readonly", "");
+ text.setTabIndex(-2);
+ } else if (textFieldEnabled
+ && text.getElement().hasAttribute("unselectable")) {
+ text.getElement().removeAttribute("unselectable");
+ text.getElement().removeAttribute("readonly");
+ text.setTabIndex(0);
+ }
+ } else {
+ text.setEnabled(textFieldEnabled);
+ }
+
if (textFieldEnabled) {
calendarToggle.setTabIndex(-1);
Roles.getButtonRole().setAriaHiddenState(
@@ -254,6 +270,20 @@ public class VPopupCalendar extends VTextualDate implements Field,
handleAriaAttributes();
}
+ /**
+ * Set correct tab index for disabled text field in IE as the value set in
+ * setTextFieldEnabled(...) gets overridden in
+ * TextualDateConnection.updateFromUIDL(...)
+ *
+ * @since
+ */
+ public void setTextFieldTabIndex() {
+ if (BrowserInfo.get().isIE() && !textFieldEnabled) {
+ // index needs to be -2 because FocusWidget updates -1 to 0 onAttach
+ text.setTabIndex(-2);
+ }
+ }
+
@Override
public void bindAriaCaption(
com.google.gwt.user.client.Element captionElement) {
@@ -426,10 +456,10 @@ public class VPopupCalendar extends VTextualDate implements Field,
public void onClose(CloseEvent<PopupPanel> event) {
if (event.getSource() == popup) {
buildDate();
- if (!BrowserInfo.get().isTouchDevice()) {
+ if (!BrowserInfo.get().isTouchDevice() && textFieldEnabled) {
/*
* Move focus to textbox, unless on touch device (avoids opening
- * virtual keyboard).
+ * virtual keyboard) or if textField is disabled.
*/
focus();
}
@@ -494,7 +524,7 @@ public class VPopupCalendar extends VTextualDate implements Field,
}
// superclass sets the text field independently when building date
- text.setEnabled(isEnabled() && isTextFieldEnabled());
+ setTextFieldEnabled(isEnabled() && isTextFieldEnabled());
}
/**
diff --git a/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java b/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java
index 6f059a7c16..7bcaaba04e 100644
--- a/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java
+++ b/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java
@@ -161,6 +161,8 @@ public class PopupDateFieldConnector extends TextualDateConnector {
getWidget().setDescriptionForAssistiveDevices(
getState().descriptionForAssistiveDevices);
+
+ getWidget().setTextFieldTabIndex();
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStates.java b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStates.java
new file mode 100644
index 0000000000..aae4a213c6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStates.java
@@ -0,0 +1,57 @@
+package com.vaadin.tests.components.datefield;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.PopupDateField;
+
+@SuppressWarnings("serial")
+public class PopupDateFieldStates extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final GridLayout gridLayout = new GridLayout(2, 2);
+ gridLayout.setSpacing(true);
+
+ gridLayout.addComponent(createPopupDateField(true, true));
+ gridLayout.addComponent(createPopupDateField(true, false));
+ gridLayout.addComponent(createPopupDateField(false, true));
+ gridLayout.addComponent(createPopupDateField(false, false));
+
+ getLayout().addComponent(gridLayout);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Test that PopupDateField is rendered consistently across browsers";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14565;
+ }
+
+ private static PopupDateField createPopupDateField(final boolean enabled,
+ final boolean textFieldEnabled) {
+ final PopupDateField popupDatefield = new PopupDateField();
+
+ Calendar cal = GregorianCalendar.getInstance();
+ cal.set(Calendar.DATE, 3);
+ cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
+ cal.set(Calendar.YEAR, 2014);
+ cal.set(Calendar.HOUR_OF_DAY, 8);
+ final Date currentDate = cal.getTime();
+
+ popupDatefield.setValue(currentDate);
+ popupDatefield.setCaption("Enabled: " + enabled
+ + ", Text field enabled: " + textFieldEnabled);
+ popupDatefield.setEnabled(enabled);
+ popupDatefield.setTextFieldEnabled(textFieldEnabled);
+ return popupDatefield;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java
new file mode 100644
index 0000000000..8c5ba20ecc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java
@@ -0,0 +1,19 @@
+package com.vaadin.tests.components.datefield;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class PopupDateFieldStatesTest extends MultiBrowserTest {
+
+ @Test
+ public void readOnlyDateFieldPopupShouldNotOpen() throws IOException,
+ InterruptedException {
+ openTestURL();
+
+ compareScreen("dateFieldStates");
+ }
+
+}