summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-08-24 13:57:27 +0300
committerVaadin Code Review <review@vaadin.com>2015-08-24 13:23:58 +0000
commitc954a7836ceb8410d6250256ddc3bc7584e76774 (patch)
tree6e0e9ec102cf0a191aeb6fe0e8517e8856cf7324
parent6322134bddd505d9cdf44f8554bb6d337dabe88a (diff)
downloadvaadin-framework-c954a7836ceb8410d6250256ddc3bc7584e76774.tar.gz
vaadin-framework-c954a7836ceb8410d6250256ddc3bc7584e76774.zip
Fix Grid column width calculation regression (#18617)
Change-Id: I359240ff393428dd5d6764d5e01a40022ab94fc6
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java6
2 files changed, 10 insertions, 5 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index 3cc02e763c..8cd97715a8 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -2973,7 +2973,9 @@ public class Grid<T> extends ResizeComposite implements
for (Column<?, T> column : visibleColumns) {
final double widthAsIs = column.getWidth();
final boolean isFixedWidth = widthAsIs >= 0;
- final double widthFixed = Math.max(widthAsIs,
+ // Check for max width just to be sure we don't break the limits
+ final double widthFixed = Math.max(
+ Math.min(getMaxWidth(column), widthAsIs),
column.getMinimumWidth());
defaultExpandRatios = defaultExpandRatios
&& (column.getExpandRatio() == -1 || column == selectionColumn);
@@ -3013,7 +3015,10 @@ public class Grid<T> extends ResizeComposite implements
double pixelsToDistribute = escalator.getInnerWidth()
- reservedPixels;
if (pixelsToDistribute <= 0 || totalRatios <= 0) {
- setColumnSizes(columnSizes);
+ if (pixelsToDistribute <= 0) {
+ // Set column sizes for expanding columns
+ setColumnSizes(columnSizes);
+ }
return;
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java
index dffa22fdc6..7f19559aec 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java
@@ -24,14 +24,14 @@ import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class GridColumnMaxWidthTest extends GridBasicFeaturesTest {
@Test
- public void testRemovingAllColumns() {
+ public void testMaxWidthAffectsColumnWidth() {
setDebug(true);
openTestURL();
selectMenuPath("Component", "Columns",
"All columns expanding, Col 0 has max width of 30px");
- assertEquals("Column 0 did not obey max width of 30px.", "30px",
- getGridElement().getCell(0, 0).getCssValue("width"));
+ assertEquals("Column 0 did not obey max width of 30px.", 30,
+ getGridElement().getCell(0, 0).getSize().getWidth());
}
} \ No newline at end of file