]> source.dussan.org Git - vaadin-framework.git/commitdiff
Form field and layout Aria corrections (#11785)
authormichaelvogt <michael@vaadin.com>
Tue, 7 May 2013 07:15:39 +0000 (10:15 +0300)
committermichaelvogt <michael@vaadin.com>
Tue, 7 May 2013 07:58:21 +0000 (10:58 +0300)
Change-Id: I7625128dd02911230ffc50d5045a88489daa85b4

client/src/com/vaadin/client/VCaption.java
client/src/com/vaadin/client/ui/VFilterSelect.java
client/src/com/vaadin/client/ui/VPopupCalendar.java
client/src/com/vaadin/client/ui/VTextField.java
client/src/com/vaadin/client/ui/VTextualDate.java

index 591aeaa436487240332350a38f3bb88aa9a964e3..d033c2b4fe5dffbab4b8dcde87a8393dc3ecadc6 100644 (file)
@@ -90,8 +90,6 @@ public class VCaption extends HTML {
         this.client = client;
         owner = component;
 
-        AriaHelper.bindCaption(component.getWidget(), getElement());
-
         if (client != null && owner != null) {
             setOwnerPid(getElement(), owner.getConnectorId());
         }
@@ -99,6 +97,24 @@ public class VCaption extends HTML {
         setStyleName(CLASSNAME);
     }
 
+    @Override
+    protected void onAttach() {
+        super.onAttach();
+
+        if (null != owner) {
+            AriaHelper.bindCaption(owner.getWidget(), getElement());
+        }
+    }
+
+    @Override
+    protected void onDetach() {
+        super.onDetach();
+
+        if (null != owner) {
+            AriaHelper.bindCaption(owner.getWidget(), null);
+        }
+    }
+
     /**
      * Updates the caption from UIDL.
      * 
index 3ad3d93abe24a1740d618eda604196511e2945a9..5ec7039462f5023dbd4ec51b5a8675cd5896a474 100644 (file)
@@ -68,6 +68,7 @@ import com.vaadin.client.UIDL;
 import com.vaadin.client.Util;
 import com.vaadin.client.VConsole;
 import com.vaadin.client.ui.aria.AriaHelper;
+import com.vaadin.client.ui.aria.HandlesAriaCaption;
 import com.vaadin.client.ui.aria.HandlesAriaInvalid;
 import com.vaadin.client.ui.aria.HandlesAriaRequired;
 import com.vaadin.client.ui.menubar.MenuBar;
@@ -85,7 +86,8 @@ import com.vaadin.shared.ui.combobox.FilteringMode;
 @SuppressWarnings("deprecation")
 public class VFilterSelect extends Composite implements Field, KeyDownHandler,
         KeyUpHandler, ClickHandler, FocusHandler, BlurHandler, Focusable,
-        SubPartAware, HandlesAriaInvalid, HandlesAriaRequired {
+        SubPartAware, HandlesAriaCaption, HandlesAriaInvalid,
+        HandlesAriaRequired {
 
     /**
      * Represents a suggestion in the suggestion popup box
@@ -1072,8 +1074,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
         tb.addBlurHandler(this);
         tb.addClickHandler(this);
 
-        Roles.getTextboxRole().set(tb.getElement());
-
         popupOpener.addClickHandler(this);
 
         setStyleName(CLASSNAME);
@@ -1846,4 +1846,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
     public void setAriaInvalid(boolean invalid) {
         AriaHelper.handleInputInvalid(tb, invalid);
     }
+
+    @Override
+    public void bindAriaCaption(Element captionElement) {
+        AriaHelper.bindCaption(tb, captionElement);
+    }
 }
index 410217a0dd60b69ef018dafca7d39e83ed470ae9..e431da127d4256fe50a2641a193ff212b05461c8 100644 (file)
@@ -39,6 +39,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.PopupPanel;
 import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
+import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.client.BrowserInfo;
 import com.vaadin.client.VConsole;
@@ -102,10 +103,10 @@ public class VPopupCalendar extends VTextualDate implements Field,
         descriptionForAssisitveDevicesElement
                 .setInnerText(PopupDateFieldState.DESCRIPTION_FOR_ASSISTIVE_DEVICES);
         AriaHelper.ensureHasId(descriptionForAssisitveDevicesElement);
-        Id.of(descriptionForAssisitveDevicesElement);
+        Roles.getTextboxRole().setAriaDescribedbyProperty(text.getElement(),
+                Id.of(descriptionForAssisitveDevicesElement));
         AriaHelper.setVisibleForAssistiveDevicesOnly(
                 descriptionForAssisitveDevicesElement, true);
-        DOM.appendChild(getElement(), descriptionForAssisitveDevicesElement);
 
         calendar = GWT.create(VCalendarPanel.class);
         calendar.setParentField(this);
@@ -118,6 +119,11 @@ public class VPopupCalendar extends VTextualDate implements Field,
             }
         });
 
+        // FIXME: Problem is, that the element with the provided id does not
+        // exist yet in html. This is the same problem as with the context menu.
+        // Apply here the same fix (#11795)
+        Roles.getTextboxRole().setAriaControlsProperty(text.getElement(),
+                Id.of(calendar.getElement()));
         Roles.getButtonRole().setAriaControlsProperty(
                 calendarToggle.getElement(), Id.of(calendar.getElement()));
 
@@ -166,6 +172,19 @@ public class VPopupCalendar extends VTextualDate implements Field,
         updateStyleNames();
     }
 
+    @Override
+    protected void onAttach() {
+        super.onAttach();
+        DOM.appendChild(RootPanel.get().getElement(),
+                descriptionForAssisitveDevicesElement);
+    }
+
+    @Override
+    protected void onDetach() {
+        super.onDetach();
+        descriptionForAssisitveDevicesElement.removeFromParent();
+    }
+
     @SuppressWarnings("deprecation")
     public void updateValue(Date newDate) {
         Date currentDate = getCurrentDate();
index 60dc5a8f2a71c1973ce9cbd5a93d65e405c4e19d..da9445c81130dc75f2f4064ea2140a5880642ae3 100644 (file)
@@ -16,7 +16,6 @@
 
 package com.vaadin.client.ui;
 
-import com.google.gwt.aria.client.Roles;
 import com.google.gwt.event.dom.client.BlurEvent;
 import com.google.gwt.event.dom.client.BlurHandler;
 import com.google.gwt.event.dom.client.ChangeEvent;
@@ -96,9 +95,6 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
         }
         addFocusHandler(this);
         addBlurHandler(this);
-
-        // Add a11y role "textbox"
-        Roles.getTextboxRole().set(node);
     }
 
     /**
index cdfd8d00c2cc694a4e5a7fa370ca6dc981a86c3f..9307455a83662662605841dc4b0be5da104f054c 100644 (file)
@@ -103,8 +103,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
             }
         });
 
-        Roles.getTextboxRole().set(text.getElement());
-
         add(text);
     }