@@ -888,8 +888,8 @@ public class Escalator extends Widget | |||
if (position instanceof AbsolutePosition) { | |||
/* | |||
* we don't want to put "top: 0" on the footer, since it'll | |||
* render wrong, as we already have | |||
* "bottom: $footer-height". | |||
* render wrong, as we already have "bottom: $footer-height" | |||
* . | |||
*/ | |||
footElem.getStyle().setLeft(-scrollLeft, Unit.PX); | |||
} else { | |||
@@ -1225,9 +1225,6 @@ public class Escalator extends Widget | |||
assertArgumentsAreValidAndWithinRange(index, numberOfRows); | |||
rows -= numberOfRows; | |||
if (heightMode == HeightMode.UNDEFINED) { | |||
heightByRows = rows; | |||
} | |||
if (!isAttached()) { | |||
return; | |||
@@ -1351,9 +1348,6 @@ public class Escalator extends Widget | |||
} | |||
rows += numberOfRows; | |||
if (heightMode == HeightMode.UNDEFINED) { | |||
heightByRows = rows; | |||
} | |||
/* | |||
* only add items in the DOM if the widget itself is attached to the | |||
@@ -2530,6 +2524,24 @@ public class Escalator extends Widget | |||
super(bodyElement); | |||
} | |||
@Override | |||
public void insertRows(int index, int numberOfRows) { | |||
super.insertRows(index, numberOfRows); | |||
if (heightMode == HeightMode.UNDEFINED) { | |||
heightByRows = getRowCount(); | |||
} | |||
} | |||
@Override | |||
public void removeRows(int index, int numberOfRows) { | |||
super.removeRows(index, numberOfRows); | |||
if (heightMode == HeightMode.UNDEFINED) { | |||
heightByRows = getRowCount(); | |||
} | |||
} | |||
@Override | |||
public void setStylePrimaryName(String primaryStyleName) { | |||
super.setStylePrimaryName(primaryStyleName); |
@@ -0,0 +1,40 @@ | |||
package com.vaadin.tests.components.grid; | |||
import com.vaadin.annotations.Theme; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.shared.ui.grid.HeightMode; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Grid; | |||
import com.vaadin.ui.VerticalLayout; | |||
@Theme("valo") | |||
public class GridUndefinedHeight extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
VerticalLayout layout = new VerticalLayout(); | |||
final Grid grid = new Grid(); | |||
grid.addColumn("toString", String.class); | |||
grid.addRow("Foo"); | |||
grid.addRow("Bar"); | |||
grid.addRow("Baz"); | |||
grid.setHeightMode(HeightMode.UNDEFINED); | |||
layout.addComponents(grid, | |||
new Button("Add header row", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
grid.appendHeaderRow(); | |||
} | |||
})); | |||
layout.setHeight("600px"); | |||
layout.setExpandRatio(grid, 1.0f); | |||
addComponent(layout); | |||
} | |||
} |
@@ -0,0 +1,47 @@ | |||
package com.vaadin.tests.components.grid; | |||
import org.junit.Assert; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.testbench.elements.GridElement; | |||
import com.vaadin.testbench.parallel.TestCategory; | |||
import com.vaadin.tests.tb3.SingleBrowserTest; | |||
@TestCategory("grid") | |||
public class GridUndefinedHeightTest extends SingleBrowserTest { | |||
@Before | |||
public void before() { | |||
setDebug(true); | |||
openTestURL(); | |||
} | |||
@Test | |||
public void grid_undefined_height() { | |||
GridElement grid = $(GridElement.class).first(); | |||
int oneRow = grid.getRow(0).getSize().getHeight(); | |||
int gridHeight = grid.getSize().getHeight(); | |||
int rows = 4; // Header Row + 3 Body Rows | |||
Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight, 1); | |||
assertNoErrorNotifications(); | |||
} | |||
@Test | |||
public void grid_undefined_height_add_header() { | |||
// Add header row to Grid | |||
$(ButtonElement.class).first().click(); | |||
GridElement grid = $(GridElement.class).first(); | |||
int oneRow = grid.getRow(0).getSize().getHeight(); | |||
int gridHeight = grid.getSize().getHeight(); | |||
int rows = 5; // 2 Header Rows + 3 Body Rows | |||
Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight); | |||
assertNoErrorNotifications(); | |||
} | |||
} |