Closed tigerasks closed 2 months ago
This seems to be fixed in Vaadin 24.4. Since 24.2 is not maintained anymore, I'd suggest to upgrade.
I've been using this reproduction:
@Route("repro")
public class Repro extends Div {
private final Grid<Integer> grid;
public Repro() {
grid = new Grid<>();
grid.setItems(1, 2, 3, 4, 5);
grid.addColumn(createLitRenderer()).setHeader("Number of array items");
var refreshButton = new NativeButton("Refresh", e -> refresh());
add(grid, refreshButton);
}
void refresh() {
grid.setItems(1, 2, 3, 4, 5, 7, 8);
grid.removeAllColumns();
grid.addColumn(createLitRenderer()).setHeader("Number of array items");
}
Renderer<Integer> createLitRenderer() {
return LitRenderer.<Integer>of("<span>${item.values.length}</span>")
.withProperty("values", v -> IntStream.range(0, v).toArray());
}
}
Description
When switching out
Grid
columns and rows, Vaadin calls the grid columns' lit renderers with undefined properties, resulting in a "Cannot read properties of undefined" error.I do not think that developers are easily aware of this or should have to account for the possibility of this happening.
Expected outcome
In the absence of computable item properties, Lit renderer should not be invoked.
Minimal reproducible example
where
issue-renderes.js
isSteps to reproduce
REPRODUCE
Toggle data
buttonIS
SHOULD Not raise an error and display the new columns and data, instead.
WORKAROUND Change
to
Environment
Vaadin version(s):
24.2.10
OS:Ubuntu 22.04.4 LTS
Browsers
Chrome