From 2ecdf7e517dffb17e90432b9d7bd7d42ad826c63 Mon Sep 17 00:00:00 2001 From: Juuso Valli Date: Tue, 29 Apr 2014 11:02:17 +0300 Subject: Fix table focusing when scrolled from the server (#10522) Change-Id: Ib18a60ae7e41af8c6c119e5b2e12e4fd5bf1069c --- client/src/com/vaadin/client/ui/VScrollTable.java | 37 ++++++++++------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 180d0d771b..4a7fc1de0a 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -1081,19 +1081,18 @@ public class VScrollTable extends FlowPanel implements HasWidgets, selected = true; keyboardSelectionOverRowFetchInProgress = true; } + if (selected) { + if (focusedRow == null + || !selectedRowKeys.contains(focusedRow + .getKey())) { + // The focus is no longer on a selected row, + // move focus to first selected row + setRowFocus(row); + } + } if (selected != row.isSelected()) { row.toggleSelection(); - if (selected) { - if (focusedRow == null - || !selectedRowKeys.contains(focusedRow - .getKey())) { - // The focus is no longer on a selected row, - // move focus to first selected row - setRowFocus(row); - } - } - if (!isSingleSelectMode() && !selected) { // Update selection range in case a row is // unselected from the middle of a range - #8076 @@ -1101,6 +1100,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } } } + } } unSyncedselectionsBeforeRowFetch = null; @@ -5301,17 +5301,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, */ public boolean isInViewPort() { int absoluteTop = getAbsoluteTop(); - int scrollPosition = scrollBodyPanel.getAbsoluteTop() - + scrollBodyPanel.getScrollPosition(); - if (absoluteTop < scrollPosition) { - return false; - } - int maxVisible = scrollPosition - + scrollBodyPanel.getOffsetHeight() - getOffsetHeight(); - if (absoluteTop > maxVisible) { - return false; - } - return true; + int absoluteBottom = absoluteTop + getOffsetHeight(); + int viewPortTop = scrollBodyPanel.getAbsoluteTop(); + int viewPortBottom = viewPortTop + + scrollBodyPanel.getOffsetHeight(); + return absoluteBottom > viewPortTop + && absoluteTop < viewPortBottom; } /** -- cgit v1.2.3