Skip to content

Commit 39578ed

Browse files
refactor(Select): rename IsUseActiveWhenValueIsNull parameter (#6390)
* feat: 更改参数 IsUseActiveWhenValueIsNull 为 IsUseDefaultItemWhenValueIsNull * test: 更新单元测试 * chore: bump version 9.8.1-beta04 --------- Co-Authored-By: Francisco Lima <[email protected]> Co-authored-by: Argo Zhang <[email protected]>
1 parent c8e95e9 commit 39578ed

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.8.1-beta03</Version>
4+
<Version>9.8.1-beta04</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Select/Select.razor.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,24 @@ public partial class Select<TValue> : ISelect, ILookup
2727
private ILookupService? InjectLookupService { get; set; }
2828

2929
/// <summary>
30-
/// 获得/设置 值为 null 时是否使用第一个选项作为默认值
31-
/// <para>Gets or sets a value indicating whether the "active" state should be used when the associated value is null.</para>
30+
/// 获得/设置 值为 null 时是否使用第一个选项或者标记为 active 的候选项作为默认值
31+
/// <para>Gets or sets a value indicating Whether to use the first option or the candidate marked as active as the default value when the value is null</para>
3232
/// </summary>
3333
[Parameter]
34-
public bool IsUseActiveWhenValueIsNull { get; set; }
34+
[Obsolete("已弃用,请使用 IsUseDefaultItemWhenValueIsNull 参数代替;Deprecated, use the IsUseDefaultItemWhenValueIsNull parameter instead")]
35+
[ExcludeFromCodeCoverage]
36+
public bool IsUseActiveWhenValueIsNull
37+
{
38+
get => IsUseDefaultItemWhenValueIsNull;
39+
set => IsUseDefaultItemWhenValueIsNull = value;
40+
}
41+
42+
/// <summary>
43+
/// 获得/设置 值为 null 时是否使用第一个选项或者标记为 active 的候选项作为默认值
44+
/// <para>Gets or sets a value indicating Whether to use the first option or the candidate marked as active as the default value when the value is null</para>
45+
/// </summary>
46+
[Parameter]
47+
public bool IsUseDefaultItemWhenValueIsNull { get; set; }
3548

3649
/// <summary>
3750
/// Gets or sets the display template. Default is null.
@@ -452,7 +465,7 @@ private async Task OnChange(ChangeEventArgs args)
452465
_lastSelectedValueString = "";
453466
_init = false;
454467

455-
return IsUseActiveWhenValueIsNull && !IsVirtualize
468+
return IsUseDefaultItemWhenValueIsNull && !IsVirtualize
456469
? SetSelectedItemState(GetItemByRows())
457470
: null;
458471
}

test/UnitTest/Components/SelectTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public async Task IsUseActiveWhenValueNull_Ok()
2727
new("1", "Test1"),
2828
new("2", "Test2") { Active = true }
2929
});
30-
pb.Add(a => a.IsUseActiveWhenValueIsNull, true);
30+
pb.Add(a => a.IsUseDefaultItemWhenValueIsNull, true);
3131
pb.Add(a => a.OnSelectedItemChanged, item =>
3232
{
3333
selectedValue = item.Value;

0 commit comments

Comments
 (0)