From 51a46a038fe0353f4babfd8218153eb68e2602ca Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Wed, 23 Oct 2013 11:23:02 +0300 Subject: [PATCH] Recovering scroll position after regression problems. (#12727) The fix for "Panels get unnecessary scroll bars in WebKit when content is 100% wide (#12727)" introduced side effects to #6731. This fix solves the problem. Change-Id: I15ca926c0ee4cad49e9eea0c578c9cc73c850588 --- client/src/com/vaadin/client/ui/VPanel.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VPanel.java b/client/src/com/vaadin/client/ui/VPanel.java index 1a87362fea..15c3883b11 100644 --- a/client/src/com/vaadin/client/ui/VPanel.java +++ b/client/src/com/vaadin/client/ui/VPanel.java @@ -218,7 +218,7 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, * Don't touch it unless you know what you're doing! Fixes ticket * #12727. * - * This solution comes from ticket #11994: Windows get unnecessary + * This solution comes from the ticket #11994: Windows get unnecessary * scroll bars in WebKit when content is 100% wide. */ if (BrowserInfo.get().isWebkit()) { @@ -227,6 +227,10 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, public void execute() { final com.google.gwt.dom.client.Element scrollable = contentNode .getFirstChildElement(); + + int contentNodeScrollTop = contentNode.getScrollTop(); + int contentNodeScrollLeft = contentNode.getScrollLeft(); + final String oldWidth = scrollable.getStyle().getWidth(); final String oldHeight = scrollable.getStyle().getHeight(); @@ -237,9 +241,12 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, scrollable.getStyle().setHeight(110, Unit.PCT); scrollable.getOffsetHeight(); scrollable.getStyle().setProperty("height", oldHeight); + + // Recovering scroll position: + contentNode.setScrollTop(contentNodeScrollTop); + contentNode.setScrollLeft(contentNodeScrollLeft); } }); } - } } -- 2.39.5