summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2018-02-06 16:51:25 +0200
committerIlia Motornyi <elmot@vaadin.com>2018-02-28 12:55:15 +0300
commitd50a8852dccc227d05788387add17fac4ea8a2e6 (patch)
tree930b7ffee1c664bc6a1006033c378f7cc40a7f74
parentd03c9d017413ba62898b1131c6af8ca3ab8c72b0 (diff)
downloadvaadin-framework-d50a8852dccc227d05788387add17fac4ea8a2e6.tar.gz
vaadin-framework-d50a8852dccc227d05788387add17fac4ea8a2e6.zip
Fix GridLayout spacing if first row/column empty and set to be hidden (#10593)
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VGridLayout.java28
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java9
2 files changed, 26 insertions, 11 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VGridLayout.java b/client/src/main/java/com/vaadin/client/ui/VGridLayout.java
index b7adf70c2c..d85a0bd0d3 100644
--- a/client/src/main/java/com/vaadin/client/ui/VGridLayout.java
+++ b/client/src/main/java/com/vaadin/client/ui/VGridLayout.java
@@ -228,11 +228,19 @@ public class VGridLayout extends ComplexPanel {
}
private int calcRowUsedSpace() {
- int usedSpace = minRowHeights[0];
+ int usedSpace = 0;
int verticalSpacing = getVerticalSpacing();
- for (int i = 1; i < minRowHeights.length; i++) {
+ boolean visibleFound = false;
+ for (int i = 0; i < minRowHeights.length; i++) {
if (minRowHeights[i] > 0 || !hiddenEmptyRow(i)) {
- usedSpace += verticalSpacing + minRowHeights[i];
+ if (visibleFound) {
+ // only include spacing if there already is a visible row
+ // before this one
+ usedSpace += verticalSpacing + minRowHeights[i];
+ } else {
+ usedSpace += minRowHeights[i];
+ visibleFound = true;
+ }
}
}
return usedSpace;
@@ -289,11 +297,19 @@ public class VGridLayout extends ComplexPanel {
* Calculates column used space
*/
private int calcColumnUsedSpace() {
- int usedSpace = minColumnWidths[0];
+ int usedSpace = 0;
int horizontalSpacing = getHorizontalSpacing();
- for (int i = 1; i < minColumnWidths.length; i++) {
+ boolean visibleFound = false;
+ for (int i = 0; i < minColumnWidths.length; i++) {
if (minColumnWidths[i] > 0 || !hiddenEmptyColumn(i)) {
- usedSpace += horizontalSpacing + minColumnWidths[i];
+ if (visibleFound) {
+ // only include spacing if there already is a visible column
+ // before this one
+ usedSpace += horizontalSpacing + minColumnWidths[i];
+ } else {
+ usedSpace += minColumnWidths[i];
+ visibleFound = true;
+ }
}
}
return usedSpace;
diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java
index 15b4f9c507..22cbddd4c4 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java
@@ -49,6 +49,7 @@ public class GridLayoutExtraSpacingTest extends MultiBrowserTest {
// Spacing off, not hiding empty rows/columns
// There should not be any spacing (red) above the csslayout
verifySpacingAbove(0, gridLayout, component);
+ verifySpacingBelow(0, gridLayout, component);
CheckBoxElement hideRowsColumnsCheckbox = $(CheckBoxElement.class)
.caption("hide empty rows/columns").first();
@@ -57,16 +58,14 @@ public class GridLayoutExtraSpacingTest extends MultiBrowserTest {
// Spacing off, hiding empty rows/columns
// There should not be any spacing (red) above the csslayout
verifySpacingAbove(0, gridLayout, component);
+ verifySpacingBelow(0, gridLayout, component);
check(spacingCheckbox);
// Spacing on, hiding empty rows/columns
// There should not be any spacing (red) above or below the csslayout
- // Oh PhantomJs...
- sleep(100);
- // FIXME: This should be 0 but there is a bug somewhere
- // verifySpacingAbove(0, gridLayout, component);
- verifySpacingBelow(6, gridLayout, component);
+ verifySpacingAbove(0, gridLayout, component);
+ verifySpacingBelow(0, gridLayout, component);
}