]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes a duplication issue in Escalator.onLoad (#12645)
authorHenrik Paul <henrik@vaadin.com>
Wed, 18 Dec 2013 12:31:12 +0000 (14:31 +0200)
committerHenrik Paul <henrik@vaadin.com>
Wed, 18 Dec 2013 12:31:15 +0000 (14:31 +0200)
Forgot about the side-effect of recalculateElementSizes(), that it already
inserts escalator rows if needed. Therefore, there's no need to explicitly add
rows into the body upon attach.

Change-Id: Id984756257c7527ca0745dcbe1d50e03a4e0ead6

client/src/com/vaadin/client/ui/grid/Escalator.java

index 97c7df2fea0abeaa0e842406ce2b088793af956b..f306166a744c078301e5b63be73feaa8c9d9b243 100644 (file)
@@ -3114,7 +3114,18 @@ public class Escalator extends Widget {
         header.paintInsertRows(0, header.getRowCount());
         footer.paintInsertRows(0, footer.getRowCount());
         recalculateElementSizes();
-        body.paintInsertRows(0, body.getRowCount());
+        /*
+         * Note: There's no need to explicitly insert rows into the body.
+         * 
+         * recalculateElementSizes will recalculate the height of the body. This
+         * has the side-effect that as the body's size grows bigger (i.e. from 0
+         * to its actual height), more escalator rows are populated. Those
+         * escalator rows are then immediately rendered. This, in effect, is the
+         * same thing as inserting those rows.
+         * 
+         * In fact, having an extra paintInsertRows here would lead to duplicate
+         * rows.
+         */
 
         scroller.attachScrollListener(verticalScrollbar.getElement());
         scroller.attachScrollListener(horizontalScrollbar.getElement());
@@ -3431,6 +3442,16 @@ public class Escalator extends Widget {
         }
     }
 
+    /**
+     * Recalculates the dimensions for all elements that require manual
+     * calculations. Also updates the dimension caches.
+     * <p>
+     * <em>Note:</em> This method has the <strong>side-effect</strong>
+     * automatically makes sure that an appropriate amount of escalator rows are
+     * present. So, if the body area grows, more <strong>escalator rows might be
+     * inserted</strong>. Conversely, if the body area shrinks,
+     * <strong>escalator rows might be removed</strong>.
+     */
     private void recalculateElementSizes() {
         if (!isAttached()) {
             return;