diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index f342e5c1725..b0ffbb83221 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 9.11.3-beta04 + 9.11.3-beta05 diff --git a/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs b/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs index d2cf9c87e9e..ef51afe828d 100644 --- a/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs +++ b/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs @@ -133,10 +133,16 @@ protected override void OnParametersSet() SubMenuIcon ??= IconTheme.GetIconByKey(ComponentIcons.CascaderSubMenuIcon); ClearIcon ??= IconTheme.GetIconByKey(ComponentIcons.SelectClearIcon); - Items ??= []; - PlaceHolder ??= Localizer[nameof(PlaceHolder)]; + Items ??= []; + if (!Items.Any()) + { + _lastValue = string.Empty; + Value = default; + return; + } + if (_lastValue != CurrentValueAsString) { _lastValue = CurrentValueAsString; diff --git a/test/UnitTest/Components/CascaderTest.cs b/test/UnitTest/Components/CascaderTest.cs index 1eab304922d..8275712591a 100644 --- a/test/UnitTest/Components/CascaderTest.cs +++ b/test/UnitTest/Components/CascaderTest.cs @@ -173,7 +173,16 @@ public void SetDefaultValue_Ok() pb.Add(a => a.Value, "1"); pb.Add(a => a.ShowFullLevels, false); }); - Assert.Empty(cut.Instance.Value); + + // 未提供数据源时 Value 赋值无效 + Assert.Null(cut.Instance.Value); + + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.Items, items); + pb.Add(a => a.Value, "3"); + pb.Add(a => a.ShowFullLevels, false); + }); } [Fact]