]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use correct column index when calculating min width during resize (#19833)
authorArtur Signell <artur@vaadin.com>
Thu, 15 Sep 2016 19:46:23 +0000 (22:46 +0300)
committerArtur Signell <artur@vaadin.com>
Thu, 15 Sep 2016 19:52:06 +0000 (22:52 +0300)
Change-Id: If7a7a5c1e5eff4bdac0f6e5943a9fac2ce98784a

client/src/main/java/com/vaadin/client/widgets/Grid.java
uitest/src/main/java/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java

index 69eec13d28b16e4655e30b7633fdd2f501e847ae..e55940582bcd548a72ebfb96f59d77943ae73015 100644 (file)
@@ -3214,7 +3214,6 @@ public class Grid<T> extends ResizeComposite implements
         private void calculate() {
             isScheduled = false;
             rescheduleCount = 0;
-
             assert !dataIsBeingFetched : "Trying to calculate column widths even though data is still being fetched.";
 
             if (columnsAreGuaranteedToBeWiderThanGrid()) {
@@ -5713,7 +5712,7 @@ public class Grid<T> extends ResizeComposite implements
                                     initialWidth = col.getWidthActual();
 
                                     minCellWidth = escalator
-                                            .getMinCellWidth(getColumns()
+                                            .getMinCellWidth(getVisibleColumns()
                                                     .indexOf(col));
                                     for (Column<?, T> c : getVisibleColumns()) {
                                         if (selectionColumn == c) {
index 777f5f67756733ba6aef4880bce006ea8419fe3f..c39feeb4daa554d6ade18e5695992784d398a977 100644 (file)
@@ -1211,6 +1211,16 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
 
                     }
                 });
+        createBooleanAction("Toggle all column hidden state", "Columns", false,
+                new Command<Grid, Boolean>() {
+                    @Override
+                    public void execute(Grid c, Boolean value, Object data) {
+                        for (Column col : grid.getColumns()) {
+                            col.setHidden(!col.isHidden());
+                        }
+                    }
+                });
+
         createBooleanAction("All columns resizable", "Columns", false,
                 new Command<Grid, Boolean>() {
 
index 7fdf7acbabad5ac6377a7995f525d061ca9c0e9a..a452a60280bc86dbc94a1a316e7516d73e16bac6 100644 (file)
@@ -146,4 +146,26 @@ public class GridColumnResizeTest extends GridBasicFeaturesTest {
         assertGreaterOrEqual("Cell got too small.", cell.getSize().getWidth(),
                 10);
     }
+
+    @Test
+    public void testShrinkColumnToZeroWithHiddenColumn() {
+        openTestURL();
+        selectMenuPath("Component", "Columns",
+                "Toggle all column hidden state");
+        // Hides although already hidden
+        selectMenuPath("Component", "Columns", "Column 0", "Hidden");
+        // Shows
+        selectMenuPath("Component", "Columns", "Column 0", "Hidden");
+        // Hides although already hidden
+        selectMenuPath("Component", "Columns", "Column 2", "Hidden");
+        // Shows
+        selectMenuPath("Component", "Columns", "Column 2", "Hidden");
+        GridCellElement cell = getGridElement().getCell(0, 1);
+        dragResizeColumn(1, 0, -cell.getSize().getWidth());
+        assertGreaterOrEqual("Cell got too small.", cell.getSize().getWidth(),
+                10);
+        assertEquals(getGridElement().getCell(0, 0).getLocation().getY(),
+                getGridElement().getCell(0, 1).getLocation().getY());
+    }
+
 }