vaadin / flow-components

Java counterpart of Vaadin Web Components
101 stars 66 forks source link

CRUD component does not set height, when Grid#setAllRowsVisible() is used #6654

Open timomeinen opened 2 months ago

timomeinen commented 2 months ago

Description of the bug

Using the CRUD component, I want to setAllRowsVisible(true):

crud.getGrid().setAllRowsVisible(true);

This sets height: auto on the Grid via all-rows-visible. But the grid is then "cutted" at the bottom by the surrounding vaadin-crud element that has a fixed size of height: 400px.

Expected behavior

When enabling setAllRowsVisible(true) the CRUD element should also get height: auto.

Alternatively, write a delegate on CRUD for setAllRowsVisible(true) that sets height on CRUD and calls grid's setAllRowsVisible(true).

Minimal reproducible example

Create CRUD with 20 elements of data and call:

crud.getGrid().setAllRowsVisible(true);

Versions

rolfsmeds commented 2 months ago

I don't think it makes sense for CRUD to change its own height based on a setting on the Grid, but I suppose we could add API in CRUD for setting all-rows-visible mode that effectively bases its height on the contents of the Grid. Although I feel that such a mode would not make sense with an editor in the bottom or aside position (i.e. I feel that it only really makes sense with an overlay editor).

timomeinen commented 2 months ago

Thank you @rolfsmeds. Makes sense.

Although, the outer element CRUD must somehow handle the situation that the inner grid enlarges. Otherwise, the grid is simply cutted and the bottom layout is missing. I wonder, if the CRUD should always have height: auto and rely on the inner grid's default height: 400px or all-rows-visible mode.

I solved it now like this:

crud.setHeight("auto");
crud.getGrid().setMinHeight(400, Unit.PIXELS);
crud.getGrid().setAllRowsVisible(true);