summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorFelype Santiago Ferreira <felype@vaadin.com>2013-10-28 11:50:18 +0200
committerVaadin Code Review <review@vaadin.com>2013-12-04 10:18:06 +0000
commitd45785d6763f269b4e00460ace07ab47c712b5ca (patch)
tree1c29213c95c152eb7eabc291bf13d5b470d42639 /client
parent26b5b672df0aa3bdefdced81ed4619c11f3e945a (diff)
downloadvaadin-framework-d45785d6763f269b4e00460ace07ab47c712b5ca.tar.gz
vaadin-framework-d45785d6763f269b4e00460ace07ab47c712b5ca.zip
Fixes right click selection focus issues in Tree. (#12618)
Change-Id: I1057424fc8956b05e15a92c32e48a767e9fc8df9
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/tree/TreeConnector.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
index ef016c31b7..7560a0f56b 100644
--- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java
+++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
@@ -18,6 +18,7 @@ package com.vaadin.client.ui.tree;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
@@ -136,9 +137,24 @@ public class TreeConnector extends AbstractComponentConnector implements
getWidget().lastSelection = getWidget().getNodeByKey(
getWidget().lastSelection.key);
}
+
if (getWidget().focusedNode != null) {
- getWidget().setFocusedNode(
- getWidget().getNodeByKey(getWidget().focusedNode.key));
+
+ Set<String> selectedIds = getWidget().selectedIds;
+
+ // If the focused node is not between the selected nodes, we need to
+ // refresh the focused node to prevent an undesired scroll. #12618.
+ if (!selectedIds.isEmpty()
+ && !selectedIds.contains(getWidget().focusedNode.key)) {
+ String keySelectedId = selectedIds.iterator().next();
+
+ TreeNode nodeToSelect = getWidget().getNodeByKey(keySelectedId);
+
+ getWidget().setFocusedNode(nodeToSelect);
+ } else {
+ getWidget().setFocusedNode(
+ getWidget().getNodeByKey(getWidget().focusedNode.key));
+ }
}
if (getWidget().lastSelection == null