If there are just 2-3 rows Vaadin Grid displays an empty space below the last one for some reason (I always wondered why it's so). In Vaadin 8 I solved this problem in the following way:
grid.setHeightByRows(size <= 12 ? size : 12);
So, if there are not so many rows grid has a smaller size without unnecessary empty space below, but if the number of rows is more than 12 it limits its height by 12 and displays a vertical scroll bar.
Could you please advise how can I implement it in Vaadin 24? There is a grid.setAllRowsVisible(true) method, but it doesn't act in the same way. First of all, it loads all elements at once which is not necessary, and also it doesn't allow limiting the maximum height in rows (I can set the height in pixels, but the counting of pixels is not fun).