summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authormichaelvogt <michael@vaadin.com>2013-08-27 10:53:23 +0200
committerVaadin Code Review <review@vaadin.com>2013-09-03 07:22:18 +0000
commitf14fc3cbd235b6004d93b10a660bb3a97d13cd64 (patch)
treeb5f69db6021269574722997392d92c612228d441 /client
parentce110b8b060d7c215f69a7e03c24ca80d88da037 (diff)
downloadvaadin-framework-f14fc3cbd235b6004d93b10a660bb3a97d13cd64.tar.gz
vaadin-framework-f14fc3cbd235b6004d93b10a660bb3a97d13cd64.zip
Keep the Tooltip in the DOM (#12458)
Change-Id: Ic707632ee51181e660b64935f68e564bdfc4443b
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java4
-rw-r--r--client/src/com/vaadin/client/VErrorMessage.java3
-rw-r--r--client/src/com/vaadin/client/VTooltip.java59
-rw-r--r--client/src/com/vaadin/client/ui/VTree.java17
-rw-r--r--client/src/com/vaadin/client/ui/tree/TreeConnector.java5
5 files changed, 54 insertions, 34 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 0d9c859ee8..2865e04757 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -490,6 +490,10 @@ public class ApplicationConnection {
// initial UIDL provided in DOM, continue as if returned by request
handleJSONText(jsonText, -1);
+
+ // Tooltip can't be created earlier because the necessary fields are
+ // not setup to add it in the correct place in the DOM
+ getVTooltip().showAssistive(new TooltipInfo(" "));
}
}
diff --git a/client/src/com/vaadin/client/VErrorMessage.java b/client/src/com/vaadin/client/VErrorMessage.java
index 2e42b98a05..a384b451dd 100644
--- a/client/src/com/vaadin/client/VErrorMessage.java
+++ b/client/src/com/vaadin/client/VErrorMessage.java
@@ -31,9 +31,6 @@ public class VErrorMessage extends FlowPanel {
public VErrorMessage() {
super();
setStyleName(CLASSNAME);
-
- // Needed for binding with WAI-ARIA attributes
- getElement().setId(DOM.createUniqueId());
}
/**
diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java
index 57e72aedfc..e687712b9c 100644
--- a/client/src/com/vaadin/client/VTooltip.java
+++ b/client/src/com/vaadin/client/VTooltip.java
@@ -15,7 +15,8 @@
*/
package com.vaadin.client;
-import com.google.gwt.aria.client.Id;
+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.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
@@ -36,12 +37,12 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.client.ui.VOverlay;
+import com.vaadin.client.ui.VWindowOverlay;
/**
* TODO open for extension
*/
-public class VTooltip extends VOverlay {
+public class VTooltip extends VWindowOverlay {
private static final String CLASSNAME = "v-tooltip";
private static final int MARGIN = 4;
public static final int TOOLTIP_EVENTS = Event.ONKEYDOWN
@@ -57,7 +58,6 @@ public class VTooltip extends VOverlay {
private boolean justClosed = false;
private String uniqueId = DOM.createUniqueId();
- private Element layoutElement;
private int maxWidth;
// Delays for the tooltip, configurable on the server side
@@ -80,17 +80,17 @@ public class VTooltip extends VOverlay {
setWidget(layout);
layout.add(em);
DOM.setElementProperty(description, "className", CLASSNAME + "-text");
-
- layoutElement = layout.getElement();
- DOM.appendChild(layoutElement, description);
+ DOM.appendChild(layout.getElement(), description);
setSinkShadowEvents(true);
- // Used to bind the tooltip to the owner for assistive devices
- layoutElement.setId(uniqueId);
-
- description.setId(DOM.createUniqueId());
- Roles.getTooltipRole().set(layoutElement);
- Roles.getTooltipRole().setAriaHiddenState(layoutElement, true);
+ // When a tooltip is shown, the content of the tooltip changes. With a
+ // tooltip being a live-area, this change is notified to a assistive
+ // device.
+ Roles.getTooltipRole().set(getElement());
+ Roles.getTooltipRole().setAriaLiveProperty(getElement(),
+ LiveValue.ASSERTIVE);
+ Roles.getTooltipRole().setAriaRelevantProperty(getElement(),
+ RelevantValue.ADDITIONS);
}
/**
@@ -240,10 +240,11 @@ public class VTooltip extends VOverlay {
@Override
public void hide() {
- super.hide();
- Roles.getTooltipRole().setAriaHiddenState(layoutElement, true);
- Roles.getTooltipRole().removeAriaDescribedbyProperty(
- tooltipEventHandler.currentElement);
+ em.updateMessage("");
+ description.setInnerHTML("");
+
+ updatePosition(null, true);
+ setPopupPosition(tooltipEventMouseX, tooltipEventMouseY);
}
private int tooltipEventMouseX;
@@ -298,9 +299,9 @@ public class VTooltip extends VOverlay {
private com.google.gwt.dom.client.Element currentElement = null;
/**
- * Current element focused
+ * Marker for handling of tooltip through focus
*/
- private boolean currentIsFocused;
+ private boolean handledByFocus;
/**
* Current tooltip active
@@ -403,6 +404,7 @@ public class VTooltip extends VOverlay {
*/
@Override
public void onBlur(BlurEvent be) {
+ handledByFocus = false;
handleHideEvent();
}
@@ -412,7 +414,7 @@ public class VTooltip extends VOverlay {
.getEventTarget());
// We can ignore move event if it's handled by move or over already
- if (currentElement == element && currentIsFocused == isFocused) {
+ if (currentElement == element && handledByFocus == true) {
return;
}
@@ -420,8 +422,6 @@ public class VTooltip extends VOverlay {
if (!connectorAndTooltipFound) {
if (isShowing()) {
handleHideEvent();
- Roles.getButtonRole()
- .removeAriaDescribedbyProperty(element);
} else {
currentTooltipInfo = null;
}
@@ -430,17 +430,12 @@ public class VTooltip extends VOverlay {
if (isShowing()) {
replaceCurrentTooltip();
- Roles.getTooltipRole().removeAriaDescribedbyProperty(
- currentElement);
} else {
showTooltip();
}
-
- Roles.getTooltipRole().setAriaDescribedbyProperty(element,
- Id.of(uniqueId));
}
- currentIsFocused = isFocused;
+ handledByFocus = isFocused;
currentElement = element;
}
}
@@ -475,9 +470,11 @@ public class VTooltip extends VOverlay {
@Override
public void setPopupPositionAndShow(PositionCallback callback) {
- super.setPopupPositionAndShow(callback);
-
- Roles.getTooltipRole().setAriaHiddenState(layoutElement, false);
+ if (isAttached()) {
+ callback.setPosition(getOffsetWidth(), getOffsetHeight());
+ } else {
+ super.setPopupPositionAndShow(callback);
+ }
}
/**
diff --git a/client/src/com/vaadin/client/ui/VTree.java b/client/src/com/vaadin/client/ui/VTree.java
index 51c00ca310..1acd4bd05f 100644
--- a/client/src/com/vaadin/client/ui/VTree.java
+++ b/client/src/com/vaadin/client/ui/VTree.java
@@ -70,6 +70,7 @@ import com.vaadin.client.ui.dd.VDragEvent;
import com.vaadin.client.ui.dd.VDropHandler;
import com.vaadin.client.ui.dd.VHasDropHandler;
import com.vaadin.client.ui.dd.VTransferable;
+import com.vaadin.client.ui.tree.TreeConnector;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.MouseEventDetails.MouseButton;
import com.vaadin.shared.ui.MultiSelectMode;
@@ -162,6 +163,9 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
/** For internal use only. May be removed or replaced in the future. */
public String[] bodyActionKeys;
+ /** For internal use only. May be removed or replaced in the future. */
+ public TreeConnector connector;
+
public VLazyExecutor iconLoaded = new VLazyExecutor(50,
new ScheduledCommand() {
@@ -1729,6 +1733,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
}
}
}
+ showTooltipForKeyboardNavigation(node);
return true;
}
@@ -1754,6 +1759,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
}
}
}
+ showTooltipForKeyboardNavigation(node);
return true;
}
@@ -1774,6 +1780,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
focusAndSelectNode(focusedNode.getParentNode());
}
}
+ showTooltipForKeyboardNavigation(focusedNode);
return true;
}
@@ -1792,6 +1799,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
focusAndSelectNode(focusedNode.getChildren().get(0));
}
}
+ showTooltipForKeyboardNavigation(focusedNode);
return true;
}
@@ -1820,6 +1828,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
selectNode(node, true);
}
sendSelectionToServer();
+ showTooltipForKeyboardNavigation(node);
return true;
}
@@ -1836,12 +1845,20 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
selectNode(node, true);
}
sendSelectionToServer();
+ showTooltipForKeyboardNavigation(node);
return true;
}
return false;
}
+ private void showTooltipForKeyboardNavigation(TreeNode node) {
+ if (connector != null) {
+ getClient().getVTooltip().showAssistive(
+ connector.getTooltipInfo(node.nodeCaptionSpan));
+ }
+ }
+
private void focusAndSelectNode(TreeNode node) {
/*
* Keyboard navigation doesn't work reliably if the tree is in
diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
index ef016c31b7..6f89137918 100644
--- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java
+++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
@@ -45,6 +45,11 @@ public class TreeConnector extends AbstractComponentConnector implements
protected final Map<TreeNode, TooltipInfo> tooltipMap = new HashMap<TreeNode, TooltipInfo>();
@Override
+ protected void init() {
+ getWidget().connector = this;
+ }
+
+ @Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
if (!isRealUpdate(uidl)) {
return;