From 1478f0a126c1b24a25d2eb92847bec7d0b3255aa Mon Sep 17 00:00:00 2001 From: capdiem Date: Tue, 22 Oct 2024 09:44:43 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(Treeview):=20initial=20value=20?= =?UTF-8?q?does=20not=20work=20(#2196)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Treeview/MTreeview.razor.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Masa.Blazor/Components/Treeview/MTreeview.razor.cs b/src/Masa.Blazor/Components/Treeview/MTreeview.razor.cs index 0235fbd3df..a297b89d55 100644 --- a/src/Masa.Blazor/Components/Treeview/MTreeview.razor.cs +++ b/src/Masa.Blazor/Components/Treeview/MTreeview.razor.cs @@ -569,15 +569,6 @@ private string CombineItemKeys(IList list) return keys; } - protected override void OnInitialized() - { - base.OnInitialized(); - - _oldActive = Active ?? []; - _oldOpen = Open ?? []; - _oldValue = Value ?? []; - } - protected override async Task OnParametersSetAsync() { await base.OnParametersSetAsync(); @@ -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)