Skip to content

Commit

Permalink
🐛 (Treeview): initial value does not work (#2196)
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem authored Oct 22, 2024
1 parent e3a3667 commit 1478f0a
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/Masa.Blazor/Components/Treeview/MTreeview.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,6 @@ private string CombineItemKeys(IList<TItem> list)
return keys;
}

protected override void OnInitialized()
{
base.OnInitialized();

_oldActive = Active ?? [];
_oldOpen = Open ?? [];
_oldValue = Value ?? [];
}

protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
Expand All @@ -600,22 +591,19 @@ protected override async Task OnParametersSetAsync()
}
}

if (!ListComparer.Equals(_oldValue, Value))
if ((ValueChanged.HasDelegate || Value != null) && !ListComparer.Equals(_oldValue, Value))
{
await HandleUpdate(_oldValue, Value, UpdateSelectedByValue, EmitSelectedAsync);
_oldValue = Value ?? [];
}

if (!ListComparer.Equals(_oldActive, Active))
if ((ActiveChanged.HasDelegate || Active != null) && !ListComparer.Equals(_oldActive, Active))
{
await HandleUpdate(_oldActive, Active, UpdateActive, EmitActiveAsync);
_oldActive = Active ?? [];
}

if (!ListComparer.Equals(_oldOpen, Open))
if ((OpenChanged.HasDelegate || Open != null) && !ListComparer.Equals(_oldOpen, Open))
{
await HandleUpdate(_oldOpen, Open, UpdateOpen, EmitOpenAsync);
_oldOpen = Open ?? [];
}

if (_prevSearch != Search)
Expand Down

0 comments on commit 1478f0a

Please sign in to comment.