fix(module: tree): SelectedNodeChanged would be fired twice twice (#1849)

This commit is contained in:
James Yeung 2021-08-17 23:36:10 +08:00 committed by GitHub
parent 53027c0221
commit 482e4a7f45
3 changed files with 12 additions and 8 deletions

View File

@ -176,8 +176,6 @@ namespace AntDesign
{
OnSelect.InvokeAsync(new TreeEventArgs<TItem>(this, treeNode));
}
UpdateBindData();
}
/// <summary>
@ -188,8 +186,6 @@ namespace AntDesign
{
if (SelectedNodesDictionary.ContainsKey(treeNode.NodeId) == true)
SelectedNodesDictionary.Remove(treeNode.NodeId);
UpdateBindData();
}
/// <summary>
@ -257,7 +253,7 @@ namespace AntDesign
/// <summary>
/// Update binding data
/// </summary>
private void UpdateBindData()
internal void UpdateBindData()
{
if (SelectedNodesDictionary.Count == 0)
{

View File

@ -68,6 +68,8 @@ namespace AntDesign
await TreeComponent.OnClick.InvokeAsync(new TreeEventArgs<TItem>(TreeComponent, SelfNode, args));
else if (TreeComponent.OnContextMenu.HasDelegate && args.Button == 2)
await TreeComponent.OnContextMenu.InvokeAsync(new TreeEventArgs<TItem>(TreeComponent, SelfNode, args));
TreeComponent.UpdateBindData();
}
/// <summary>

View File

@ -2,6 +2,7 @@
DefaultExpandedKeys="@(new[] { "0-0-0", "0-0-1"})"
DefaultSelectedKeys="@(new[] {"0-0-0", "0-0-1" })"
DefaultCheckedKeys="@(new[] {"0-0-0", "0-0-1" })"
SelectedNodeChanged="SelectedNodeChanged"
OnSelect="OnSelect"
OnCheck="OnCheck">
<Nodes>
@ -29,13 +30,18 @@
@code{
void OnSelect(TreeEventArgs<string> args)
void OnSelect(TreeEventArgs<string> args)
{
Console.WriteLine("OnSelect");
Console.WriteLine($"OnSelect {args.Node.Key}");
}
void OnCheck(TreeEventArgs<string> args)
{
Console.WriteLine("onCheck");
Console.WriteLine($"OnCheck {args.Node.Key}");
}
void SelectedNodeChanged(TreeNode<string> e)
{
Console.WriteLine($"SelectedNodeChanged: {e?.Key}");
}
}