From 0e9ff32598ed86d5f24a8bce5c5c898d81dc2c84 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Wed, 2 Oct 2013 16:33:41 +0300 Subject: Ported regression fixes in 6.8 for #12407 to 7.1 branch Change-Id: Ie46ab97fc1ff89dd241eec9182ed0f92164b754d --- client/src/com/vaadin/client/ui/VScrollTable.java | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 492730259a..6e9e28ff25 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -1113,14 +1113,16 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private ScheduledCommand lazyScroller = new ScheduledCommand() { @Override public void execute() { - if (firstvisibleOnLastPage > -1) { - scrollBodyPanel - .setScrollPosition(measureRowHeightOffset(firstvisibleOnLastPage)); - } else { - scrollBodyPanel - .setScrollPosition(measureRowHeightOffset(firstvisible)); + if (firstvisible > 0) { + firstRowInViewPort = firstvisible; + if (firstvisibleOnLastPage > -1) { + scrollBodyPanel + .setScrollPosition(measureRowHeightOffset(firstvisibleOnLastPage)); + } else { + scrollBodyPanel + .setScrollPosition(measureRowHeightOffset(firstvisible)); + } } - firstRowInViewPort = firstvisible; } }; @@ -1131,17 +1133,15 @@ public class VScrollTable extends FlowPanel implements HasWidgets, firstvisibleOnLastPage = uidl.hasVariable("firstvisibleonlastpage") ? uidl .getIntVariable("firstvisibleonlastpage") : -1; if (firstvisible != lastRequestedFirstvisible && scrollBody != null) { - // received 'surprising' firstvisible from server: scroll there - firstRowInViewPort = firstvisible; + // Update lastRequestedFirstvisible right away here // (don't rely on update in the timer which could be cancelled). lastRequestedFirstvisible = firstRowInViewPort; - /* - * Schedule the scrolling to be executed last so no updates to the - * rows affect scrolling measurements. - */ - Scheduler.get().scheduleFinally(lazyScroller); + // Only scroll if the first visible changes from the server side. + // Else we might unintentionally scroll even when the scroll + // position has not changed. + Scheduler.get().scheduleDeferred(lazyScroller); } } @@ -2160,7 +2160,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets, isNewBody = false; - Scheduler.get().scheduleFinally(lazyScroller); + if (firstvisible > 0) { + Scheduler.get().scheduleDeferred(lazyScroller); + } if (enabled) { // Do we need cache rows -- cgit v1.2.3