mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-03 12:37:40 +08:00
fix(module: tree): SelectedNodeChanged would be fired twice twice (#1849)
This commit is contained in:
parent
53027c0221
commit
482e4a7f45
@ -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)
|
||||
{
|
||||
|
@ -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>
|
||||
|
@ -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}");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user