*/
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(
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) {
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();
}
}
// superclass sets the text field independently when building date
- text.setEnabled(isEnabled() && isTextFieldEnabled());
+ setTextFieldEnabled(isEnabled() && isTextFieldEnabled());
}
/**
getWidget().setDescriptionForAssistiveDevices(
getState().descriptionForAssistiveDevices);
+
+ getWidget().setTextFieldTabIndex();
}
@Override
--- /dev/null
+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;
+ }
+
+}
--- /dev/null
+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");
+ }
+
+}