Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
davidef opened this issue Jan 24, 2025 · 0 comments

Comments

@davidef
Copy link

davidef commented Jan 24, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant