aboutsummaryrefslogtreecommitdiffstats
path: root/client/src/com
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-01-28 15:50:54 +0200
committerVaadin Code Review <review@vaadin.com>2015-02-25 12:20:33 +0000
commitea65f173ff5f4d7c980f1e2d1d03c42470d30a2e (patch)
treed23897feb999370319cfa7ae062a0ec0a60ec9dd /client/src/com
parent0dae6ff2f414874e2f05a4475f6ff1c2c6b071a4 (diff)
downloadvaadin-framework-ea65f173ff5f4d7c980f1e2d1d03c42470d30a2e.tar.gz
vaadin-framework-ea65f173ff5f4d7c980f1e2d1d03c42470d30a2e.zip
Maintain Grid scroll position on detach and reattach (#16220)
Change-Id: I6ac5c3304bcd22e23f298c4dbdd65358aa1c64f7
Diffstat (limited to 'client/src/com')
-rw-r--r--client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java11
-rw-r--r--client/src/com/vaadin/client/widgets/Escalator.java27
2 files changed, 36 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java b/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java
index 21f56c6c4d..2345641408 100644
--- a/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java
+++ b/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java
@@ -335,7 +335,7 @@ public abstract class ScrollbarBundle implements DeferredWorker {
private boolean isLocked = false;
- /** @deprecarted access via {@link #getHandlerManager()} instead. */
+ /** @deprecated access via {@link #getHandlerManager()} instead. */
@Deprecated
private HandlerManager handlerManager;
@@ -515,6 +515,15 @@ public abstract class ScrollbarBundle implements DeferredWorker {
}
/**
+ * Should be called whenever this bundle is attached to the DOM (typically,
+ * from the onLoad of the containing widget). Used to ensure the DOM scroll
+ * position is maintained when detaching and reattaching the bundle.
+ */
+ public void onLoad() {
+ internalSetScrollPos(toInt32(scrollPos));
+ }
+
+ /**
* Truncates a double such that no decimal places are retained.
* <p>
* E.g. {@code trunc(2.3d) == 2.0d} and {@code trunc(-2.3d) == -2.0d}.
diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java
index a81d0f3e18..129100e073 100644
--- a/client/src/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/com/vaadin/client/widgets/Escalator.java
@@ -47,6 +47,7 @@ import com.google.gwt.dom.client.TableRowElement;
import com.google.gwt.dom.client.TableSectionElement;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.logging.client.LogConfiguration;
+import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RequiresResize;
@@ -4479,7 +4480,28 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
header.paintInsertRows(0, header.getRowCount());
footer.paintInsertRows(0, footer.getRowCount());
- recalculateElementSizes();
+
+ // recalculateElementSizes();
+
+ Scheduler.get().scheduleDeferred(new Command() {
+ @Override
+ public void execute() {
+ /*
+ * Not a faintest idea why we have to defer this call, but
+ * unless it is deferred, the size of the escalator will be 0x0
+ * after it is first detached and then reattached to the DOM.
+ * This only applies to a bare Escalator; inside a Grid
+ * everything works fine either way.
+ *
+ * The three autodetectRowHeightLater calls above seem obvious
+ * suspects at first. However, they don't seem to have anything
+ * to do with the issue, as they are no-ops in the
+ * detach-reattach case.
+ */
+ recalculateElementSizes();
+ }
+ });
+
/*
* Note: There's no need to explicitly insert rows into the body.
*
@@ -4506,6 +4528,9 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
footer.reapplyColumnWidths();
}
+ verticalScrollbar.onLoad();
+ horizontalScrollbar.onLoad();
+
scroller.attachScrollListener(verticalScrollbar.getElement());
scroller.attachScrollListener(horizontalScrollbar.getElement());
scroller.attachMousewheelListener(getElement());