Skip to content

Commit

Permalink
Fix Grid column width calculation regression (#18617)
Browse files Browse the repository at this point in the history
Change-Id: I359240ff393428dd5d6764d5e01a40022ab94fc6
  • Loading branch information
Teemu Suo-Anttila authored and Vaadin Code Review committed Aug 24, 2015
1 parent 6322134 commit c954a78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions client/src/com/vaadin/client/widgets/Grid.java
Expand Up @@ -2973,7 +2973,9 @@ private void applyColumnWidthsWithExpansion() {
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);
Expand Down Expand Up @@ -3013,7 +3015,10 @@ private void applyColumnWidthsWithExpansion() {
double pixelsToDistribute = escalator.getInnerWidth()
- reservedPixels;
if (pixelsToDistribute <= 0 || totalRatios <= 0) {
setColumnSizes(columnSizes);
if (pixelsToDistribute <= 0) {
// Set column sizes for expanding columns
setColumnSizes(columnSizes);
}
return;
}

Expand Down
Expand Up @@ -24,14 +24,14 @@
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());
}
}

0 comments on commit c954a78

Please sign in to comment.