Browse Source

Correctly detach components in merged cells (#8773)

* Correctly detach components in merged cells

This was already once fixed in 7.7 in #8142
tags/8.1.0.alpha1
Artur 7 years ago
parent
commit
610c6522da

+ 7
- 0
server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java View File

@@ -388,6 +388,13 @@ public abstract class StaticSection<ROW extends StaticSection.StaticRow<?>>
for (CELL cell : cells.values()) {
cell.detach();
}
for (CellState cellState : rowState.cellGroups.keySet()) {
if (cellState.type == GridStaticCellType.WIDGET
&& cellState.connector != null) {
((Component) cellState.connector).setParent(null);
cellState.connector = null;
}
}
}

void checkIfAlreadyMerged(String columnId) {

+ 21
- 0
server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java View File

@@ -63,6 +63,17 @@ public class GridChildrenTest {
Assert.assertNull(label.getParent());
}

@Test
public void removeHeaderWithComponentInMergedHeaderCell() {
HeaderCell merged = grid.getDefaultHeaderRow().join("foo", "bar",
"baz");
Label label = new Label();
merged.setComponent(label);
Assert.assertEquals(grid, label.getParent());
grid.removeHeaderRow(0);
Assert.assertNull(label.getParent());
}

@Test
public void removeComponentInMergedFooterCell() {
FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz");
@@ -73,6 +84,16 @@ public class GridChildrenTest {
Assert.assertNull(label.getParent());
}

@Test
public void removeFooterWithComponentInMergedFooterCell() {
FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz");
Label label = new Label();
merged.setComponent(label);
Assert.assertEquals(grid, label.getParent());
grid.removeFooterRow(0);
Assert.assertNull(label.getParent());
}

@Test
public void componentsInMergedFooter() {
FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz");

Loading…
Cancel
Save