summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMika Murtojarvi <mika@vaadin.com>2015-07-31 17:10:31 +0300
committerVaadin Code Review <review@vaadin.com>2015-08-06 07:30:44 +0000
commit961f10856af47b59ac8915e06f9ad9f2c0785dfa (patch)
treefe7f6428835b9ec39937bd1b1d514bf450d520dc /client
parent55dc0ade6455056ce2bd910b34ddf9e242845d24 (diff)
downloadvaadin-framework-961f10856af47b59ac8915e06f9ad9f2c0785dfa.tar.gz
vaadin-framework-961f10856af47b59ac8915e06f9ad9f2c0785dfa.zip
Prevent scrolling when expanding a TreeTable item (#18247)
Change-Id: I837ee83a75337eef4338e7206cdd0e366b24f183
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. */