Open enver-haase opened 6 months ago
Looks like duplicate of: https://github.com/vaadin/flow-components/issues/1236
With the following change issue goes away
Replace Button code with:
Button button = new Button("Revalidate!",
e -> refreshChildItems(treeGrid, treeData.getRootItems()));
And add recursive refreshItem method
private void refreshChildItems(TreeGrid<String> grid,
List<String> rootItems) {
for (String item : rootItems) {
grid.getDataProvider().refreshItem(item, false);
refreshChildItems(grid, grid.getTreeData().getChildren(item));
}
}
See also: https://github.com/vaadin/flow-components/issues/1050#issuecomment-957465512
Javadocs for TreeGrid refreshAll should mention the limitation and propose using refreshItem instead.
If I move one root item under another one, so that
A
B
becomes
> B (with A underneath)
then I cannot refresh the underlying DataProvider in such a way that A disappears from the view, using only refreshItem()
.
Minor side note to the workaround of Tatu. It works indeed, but it is also significant slower. We have a case, where the refresh time goes from ~5s to around 35s (a tree grid with roughly 44k rows and all expanded initially).
So not suitable for all situations.
Description of the bug
When I re-validate the tree, I expect this to be a no-op if there is nothing to do. Certainly it should not scroll. This is bad UX.
Expected behavior
Re-validating a validated tree should be a no-op. In any case, when I drop an item using drag-and-drop, the tree should not jump away from underneath the mouse pointer.
Minimal reproducible example
Versions