summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeader.java22
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeaderTest.java30
3 files changed, 54 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java
index fd32ca8243..e382d2a4f1 100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -3411,6 +3411,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
// Make SelectAllCheckbox visible
getSelectionColumn().ifPresent(col -> {
+ if (getDefaultHeaderRow() == null)
+ return;
HeaderCell headerCell = getDefaultHeaderRow().getCell(col);
if (headerCell.getType().equals(GridStaticCellType.WIDGET)) {
// SelectAllCheckbox is present already
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeader.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeader.java
new file mode 100644
index 0000000000..b7d54aa9b1
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeader.java
@@ -0,0 +1,22 @@
+package com.vaadin.tests.components.grid;
+
+import com.vaadin.data.ValueProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+
+public class GridColumnWidthWithoutHeader extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ Grid<String> grid = new Grid<>();
+ grid.addColumn(ValueProvider.identity()).setExpandRatio(1)
+ .setMinimumWidth(250);
+ grid.addColumn(String::valueOf).setWidth(150);
+ grid.setItems("a", "b");
+ grid.setSelectionMode(Grid.SelectionMode.MULTI);
+ grid.setSizeFull();
+
+ grid.removeHeaderRow(0);
+ addComponent(grid);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeaderTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeaderTest.java
new file mode 100644
index 0000000000..c9208e3226
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthWithoutHeaderTest.java
@@ -0,0 +1,30 @@
+package com.vaadin.tests.components.grid;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class GridColumnWidthWithoutHeaderTest extends SingleBrowserTest {
+ public static final int THRESHOLD = 3;
+
+ @Test
+ public void testWidthWithoutHeader() {
+ openTestURL();
+
+ GridElement grid = $(GridElement.class).first();
+ int columnsWidth = getColWidthsRounded(grid);
+ assertTrue(Math
+ .abs(columnsWidth - grid.getSize().getWidth()) <= THRESHOLD);
+ }
+
+ private int getColWidthsRounded(GridElement grid) {
+ GridElement.GridRowElement firstRow = grid.getRow(0);
+ int width = 0;
+ for (int i = 0; i < 3; i++) {
+ width = width + firstRow.getCell(i).getSize().getWidth();
+ }
+ return width;
+ }
+}