flow-components icon indicating copy to clipboard operation
flow-components copied to clipboard

Grid: ItemDetails of first 3 rows is not initially hidden when columns are added after grid initialization

Open davidef opened this issue 1 year ago • 0 comments

Description

ItemDetails of first 3 rows is not initially hidden when columns are added after grid initialisation. If we add the columns before initial rendering or remove the columns and add them again ItemDetails are hidden as expected.

Image

Expected outcome

ItemDetails is hidden even if columns are created after grid initialisation

Minimal reproducible example

public class GridView extends VerticalLayout {
	public GridView() {
		setHeightFull();
		
		Grid<Item> grid = new Grid<>();
		add(grid);
		
		Button  b = new Button("add columns", e -> {
			if (grid.getColumns().size() > 0) {
				grid.removeAllColumns();
			}
			
			grid.addColumn(Item::name)
				.setHeader("Name")
				.setFlexGrow(1);
			
			List<Item> items = List.of(
					new Item("A"),
					new Item("B"),
					new Item("C"),
					new Item("D"),
					new Item("E")
					);
			grid.setItems(items);
			
			grid.setItemDetailsRenderer(new ComponentRenderer<>(item -> {
				return new Span(item.name());
			}));
		});
		add(b);
	}
	
	public static record Item(String name) {};
}

Steps to reproduce

Click "add columns" a "gap" for ItemDetail is present for the first 3 row (even if the ItemDetail it self is not rendered)

Environment

Vaadin version(s): 24.6.2

Browsers

Firefox, Chrome, Edge, Safari

davidef avatar Jan 24 '25 12:01 davidef