diff options
author | michaelvogt <michael@vaadin.com> | 2013-05-07 15:33:43 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-05-17 10:42:26 +0000 |
commit | 2f6d5e0d8c7cf4912bb82207c0dbe26101d168cb (patch) | |
tree | c76690fc065077e8d04b01a486c81fa56bb249c0 | |
parent | 6c64757b35fa4f0f1100546f1a0bc44b71f87a85 (diff) | |
download | vaadin-framework-2f6d5e0d8c7cf4912bb82207c0dbe26101d168cb.tar.gz vaadin-framework-2f6d5e0d8c7cf4912bb82207c0dbe26101d168cb.zip |
Tooltip accessibility fixes (#11799)
Remove previously added attribute for WAI-ARIA live area
Set overlay container as live area instead
Change-Id: Ie75c2993fdb42f29f307cbd294ae3352d2ef1ce3
-rw-r--r-- | client/src/com/vaadin/client/ApplicationConnection.java | 26 | ||||
-rw-r--r-- | client/src/com/vaadin/client/VTooltip.java | 5 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/ui/UIConnector.java | 5 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/UI.java | 24 | ||||
-rw-r--r-- | shared/src/com/vaadin/shared/ui/ui/UIState.java | 6 |
5 files changed, 61 insertions, 5 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 1faf39394d..4141f9f2dc 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -27,6 +27,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.google.gwt.aria.client.LiveValue; +import com.google.gwt.aria.client.RelevantValue; +import com.google.gwt.aria.client.Roles; import com.google.gwt.core.client.Duration; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; @@ -81,6 +84,7 @@ import com.vaadin.client.ui.AbstractConnector; import com.vaadin.client.ui.VContextMenu; import com.vaadin.client.ui.VNotification; import com.vaadin.client.ui.VNotification.HideEvent; +import com.vaadin.client.ui.VOverlay; import com.vaadin.client.ui.dd.VDragAndDropManager; import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.client.ui.window.WindowConnector; @@ -456,6 +460,15 @@ public class ApplicationConnection { webkitMaybeIgnoringRequests = true; } }); + + // Ensure the overlay container is added to the dom and set as a live + // area for assistive devices + Element overlayContainer = VOverlay.getOverlayContainer(this); + Roles.getAlertRole().setAriaLiveProperty(overlayContainer, + LiveValue.ASSERTIVE); + setOverlayContainerLabel(getUIConnector().getState().overlayContainerLabel); + Roles.getAlertRole().setAriaRelevantProperty(overlayContainer, + RelevantValue.ADDITIONS); } /** @@ -3421,4 +3434,17 @@ public class ApplicationConnection { public void handlePushMessage(String message) { handleJSONText(message, 200); } + + /** + * Set the label of the container element, where tooltip, notification and + * dialgs are added to. + * + * @param overlayContainerLabel + * label for the container + */ + public void setOverlayContainerLabel(String overlayContainerLabel) { + Roles.getAlertRole().setAriaLabelProperty( + VOverlay.getOverlayContainer(this), + getUIConnector().getState().overlayContainerLabel); + } } diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index 61d155d668..6191821988 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -16,7 +16,6 @@ package com.vaadin.client; import com.google.gwt.aria.client.Id; -import com.google.gwt.aria.client.LiveValue; import com.google.gwt.aria.client.Roles; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -86,10 +85,8 @@ public class VTooltip extends VOverlay { DOM.appendChild(layoutElement, description); setSinkShadowEvents(true); - // WAI-ARIA additions + // Used to bind the tooltip to the owner for assistive devices layoutElement.setId(uniqueId); - Roles.getTooltipRole().setAriaLiveProperty(getElement(), - LiveValue.POLITE); description.setId(DOM.createUniqueId()); Roles.getTooltipRole().set(layoutElement); diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 67cba1d3ea..643d687f1d 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -629,6 +629,11 @@ public class UIConnector extends AbstractSingleComponentContainerConnector if (stateChangeEvent.hasPropertyChanged("pushMode")) { getConnection().setPushEnabled(getState().pushMode.isEnabled()); } + + if (stateChangeEvent.hasPropertyChanged("overlayContainerLabel")) { + getConnection().setOverlayContainerLabel( + getState().overlayContainerLabel); + } } private void configurePolling() { diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 2e9570fa09..e077b003b8 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -1333,4 +1333,28 @@ public abstract class UI extends AbstractSingleComponentContainer implements getState().pushMode = pushMode; } + /** + * Get the label that is added to the container element, where tooltip, + * notification and dialogs are added to. + * + * @return the label of the container + */ + public String getOverlayContainerLabel() { + return getState().overlayContainerLabel; + } + + /** + * Sets the label that is added to the container element, where tooltip, + * notifications and dialogs are added to. + * <p> + * This is helpful for users of assistive devices, as this element is + * reachable for them. + * </p> + * + * @param overlayContainerLabel + * label to use for the container + */ + public void setOverlayContainerLabel(String overlayContainerLabel) { + getState().overlayContainerLabel = overlayContainerLabel; + } } diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java index 2565de59df..16c1ed16c7 100644 --- a/shared/src/com/vaadin/shared/ui/ui/UIState.java +++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java @@ -27,6 +27,10 @@ public class UIState extends TabIndexState { public PushMode pushMode = PushMode.DISABLED; + // Informing users of assistive devices, that the content of this container + // is announced automatically and does not need to be navigated into + public String overlayContainerLabel = "This content is announced automatically and does not need to be navigated into."; + public static class LoadingIndicatorConfigurationState implements Serializable { public int firstDelay = 300; @@ -52,4 +56,4 @@ public class UIState extends TabIndexState { // Default is 1 for legacy reasons tabIndex = 1; } -}
\ No newline at end of file +} |