Skip to content

Commit c541b46

Browse files
authored
fix(module: tree): would not invoke CheckedKeys changed while CheckStrictly was set (ant-design-blazor#3379)
1 parent 9826983 commit c541b46

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

components/tree/TreeNode.razor.cs

+17-12
Original file line numberDiff line numberDiff line change
@@ -445,23 +445,26 @@ private async void OnCheckBoxClick(MouseEventArgs args)
445445
/// <param name="check"></param>
446446
public void SetChecked(bool check)
447447
{
448-
if (!Disabled)
448+
if (Disabled)
449449
{
450-
if (TreeComponent.CheckStrictly)
451-
{
452-
this.Checked = check;
453-
}
454-
else
455-
{
456-
SetChildChecked(this, check);
457-
if (ParentNode != null)
458-
ParentNode.UpdateCheckState();
459-
}
450+
return;
451+
}
452+
453+
if (TreeComponent.CheckStrictly)
454+
{
455+
this.Checked = check;
460456
}
461457
else
462-
TreeComponent.AddOrRemoveCheckNode(this);
458+
{
459+
SetChildChecked(this, check);
460+
if (ParentNode != null)
461+
ParentNode.UpdateCheckState();
462+
}
463+
464+
TreeComponent.AddOrRemoveCheckNode(this);
463465
StateHasChanged();
464466
}
467+
465468
/// <summary>
466469
/// Set the checkbox state when ini
467470
/// </summary>
@@ -496,6 +499,7 @@ private void SetChildChecked(TreeNode<TItem> subnode, bool check)
496499
foreach (var child in subnode.ChildNodes)
497500
child?.SetChildChecked(child, check);
498501
}
502+
499503
/// <summary>
500504
/// Sets the checkbox status of child nodes whern bind default
501505
/// </summary>
@@ -574,6 +578,7 @@ private void UpdateCheckState(bool? halfChecked = null)
574578
if (ParentNode == null)
575579
StateHasChanged();
576580
}
581+
577582
/// <summary>
578583
/// Update check status when bind default
579584
/// </summary>

0 commit comments

Comments
 (0)