I have a tree structure which has over 10.000 items.
I use Virtualize to lazy render items.
When I @bind tree state to item.
Then the connection between root and children is broken after the second level virtualized nodes.
Example:
| - level 1.1 // working---- | level 2.1 // not working---- ---- | level 3.1 // not working---- | level 2.2 // not working| - level 1.2 // working---- | level 2.3 // not workingTree state:
record TreeState( ITree Structure, INode SelectedNode)Tree root:
<h1>@State.SelectedNode.Id</h1>@code { var TreeState State { get; set; }<ul><Virtualize Items="@treeStructure" Context="node"><NodeComponent @key="node.Id" Node="@node" @bind-State="@State" /></Virtualize></ul>}Tree node:
<li @onclick="@(() => SelectNode())"><b>Node.Name</b> @if(Node.HasChildren) {<ul><Virtualize Items="@Node.Children" Context="node"><NodeComponent @key="node.Id" Node="@node" @bind-State="@State" /></Virtualize></ul> }</li>@code { [Parameter] public INode Node { get; set; } [Parameter] public TreeState State { get; set; } [Parameter] public EventCallback<TreeState> StateChanged { get; set; } private void SelectNode() { var newState = State with { SelectedNode = Node }; StateChanged.InvokeAsync(newState); // This line is invoked correctly in debugger. // But the parent is never updated if click on second level of the tree and beyond. }}I already have an alternative for @bind therefore I am NOT interested in alternatives or workarounds.
How to make @bind work if clicked on the second level of nodes? Or at least I want to know if it is a bug from Microsoft or my misuse?