From 2e3e877e1bf99bbaf89d5dc45625ab44322c20e0 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 6 Nov 2013 15:11:34 +0200 Subject: [PATCH] Fix scroll position handling in Window Webkit hack (#12736) Change-Id: If4d17c34b2d20ad983f21b892d3ab4c68f511780 --- client/src/com/vaadin/client/ui/VWindow.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 396169eb8c..73b57c7e5b 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -360,6 +360,12 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, public void execute() { final com.google.gwt.dom.client.Element scrollable = contents .getFirstChildElement(); + + // Adjusting the width or height may change the scroll + // position, so store the current position + int horizontalScrollPosition = scrollable.getScrollLeft(); + int verticalScrollPosition = scrollable.getScrollTop(); + final String oldWidth = scrollable.getStyle().getWidth(); final String oldHeight = scrollable.getStyle().getHeight(); @@ -371,6 +377,10 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, scrollable.getOffsetHeight(); scrollable.getStyle().setProperty("height", oldHeight); + // Restore the scroll position + scrollable.setScrollLeft(horizontalScrollPosition); + scrollable.setScrollTop(verticalScrollPosition); + updateContentsSize(); positionOrSizeUpdated(); } -- 2.39.5