Skip to content

ScrollToItem corrupts tree data #53

@andersforsell

Description

@andersforsell

With Vaadin 24.3.3 and selection-grid-flow version 3.0.3 I sometimes see problems that the tree data is corrupted, for example child nodes are empty.

The below code reproduces the problem if you click the button and then expand the tree data, see also snapshot.

public class MainView extends VerticalLayout {
	public MainView() {
	  SelectionTreeGrid<String> treeGrid = new SelectionTreeGrid<>();
    treeGrid.addHierarchyColumn(String::toString);
    TreeData<String> treeData = new TreeData<>();
    for (int i = 1; i <= 10; i++) {
        String topLevelItem = "Item " + i;
        treeData.addItem(null, topLevelItem);
        for (int j = 1; j <= 3; j++) {
            String subItem = "Subitem " + (i * 10 + j);
            treeData.addItem(topLevelItem, subItem);
            for (int k = 1; k <= 3; k++) {
                String subSubItem = "Subsubitem " + (i * 100 + j * 10 + k);
                treeData.addItem(subItem, subSubItem);
            }
        }
    }
    treeGrid.setDataProvider(new TreeDataProvider<>(treeData));
    Button button = new Button("Select Item", e -> {
      treeGrid.scrollToItem("Subsubitem 512");
      treeGrid.select("Subsubitem 512");
    });
    add(treeGrid, button);
	}
}

Screenshot 2024-02-09 133039

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions