aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMika Murtojarvi <mika@vaadin.com>2015-07-31 17:10:31 +0300
committerpatrik <patrik@vaadin.com>2015-08-12 16:06:56 +0300
commit895fd492ced091302d64be4350d3b44e4490896d (patch)
tree08752f1e44eda486a5c31fc0203b02f97e31f334 /client
parent2da9519826a07376b8e282ef7ea2b07939509748 (diff)
downloadvaadin-framework-895fd492ced091302d64be4350d3b44e4490896d.tar.gz
vaadin-framework-895fd492ced091302d64be4350d3b44e4490896d.zip
Prevent scrolling when expanding a TreeTable item (#18247)
Change-Id: I0877b848b051413e1c2a8af29f066003bdc744ab
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VScrollTable.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index e036725ceb..4e030b8e49 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -1295,8 +1295,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
if (uidl.hasVariable("selected")) {
final Set<String> selectedKeys = uidl
.getStringArrayVariableAsSet("selected");
- removeUnselectedRowKeys(selectedKeys);
-
+ // Do not update focus if there is a single selected row
+ // that is the same as the previous selection. This prevents
+ // unwanted scrolling (#18247).
+ boolean rowsUnSelected = removeUnselectedRowKeys(selectedKeys);
+ boolean updateFocus = rowsUnSelected || selectedRowKeys.size() == 0
+ || focusedRow == null;
if (scrollBody != null) {
Iterator<Widget> iterator = scrollBody.iterator();
while (iterator.hasNext()) {
@@ -1313,7 +1317,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
selected = true;
keyboardSelectionOverRowFetchInProgress = true;
}
- if (selected && selectedKeys.size() == 1) {
+ if (selected && selectedKeys.size() == 1 && updateFocus) {
/*
* If a single item is selected, move focus to the
* selected row. (#10522)
@@ -1338,14 +1342,14 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
return keyboardSelectionOverRowFetchInProgress;
}
- private void removeUnselectedRowKeys(final Set<String> selectedKeys) {
+ private boolean removeUnselectedRowKeys(final Set<String> selectedKeys) {
List<String> unselectedKeys = new ArrayList<String>(0);
for (String key : selectedRowKeys) {
if (!selectedKeys.contains(key)) {
unselectedKeys.add(key);
}
}
- selectedRowKeys.removeAll(unselectedKeys);
+ return selectedRowKeys.removeAll(unselectedKeys);
}
/** For internal use only. May be removed or replaced in the future. */