From ede7ae44d8573a4fa1052204940245fcb2c402ac Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 18 May 2011 09:56:28 +0000 Subject: [PATCH] #5547 Table horizontal scroller goes out of sync in Chrome when changing visible columns svn changeset:18881/svn branch:6.6 --- src/com/vaadin/terminal/gwt/client/Util.java | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index 70af13bd4b..7edad795fe 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -589,6 +589,7 @@ public class Util { // check the scrolltop value before hiding the element final int scrolltop = elem.getScrollTop(); + final int scrollleft = elem.getScrollLeft(); elem.getStyle().setProperty("overflow", "hidden"); Scheduler.get().scheduleDeferred(new Command() { @@ -598,7 +599,7 @@ public class Util { if (scrolltop > 0 || elem.getScrollTop() > 0) { int scrollvalue = scrolltop; - if (scrolltop == 0) { + if (scrollvalue == 0) { // mysterious are the ways of webkits scrollbar // handling. In some cases webkit reports bad (0) // scrolltop before hiding the element temporary, @@ -610,6 +611,25 @@ public class Util { elem.setScrollTop(scrollvalue - 1); elem.setScrollTop(scrollvalue); } + + // fix for #5547: Table horizontal scroll sometimes not + // updated when collapsing/expanding columns + if (BrowserInfo.get().isChrome() + && (scrollleft > 0 || elem.getScrollLeft() > 0)) { + int scrollvalue = scrollleft; + + if (scrollvalue == 0) { + // mysterious are the ways of webkits scrollbar + // handling. In some cases webkit may report a bad + // (0) scrollleft before hiding the element + // temporary, sometimes after. + scrollvalue = elem.getScrollLeft(); + } + // fix another bug where scrollbar remains in wrong + // position + elem.setScrollLeft(scrollvalue - 1); + elem.setScrollLeft(scrollvalue); + } } }); } -- 2.39.5