Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.8.1-beta03</Version>
<Version>9.8.1-beta04</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
21 changes: 17 additions & 4 deletions src/BootstrapBlazor/Components/Select/Select.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,24 @@ public partial class Select<TValue> : ISelect, ILookup
private ILookupService? InjectLookupService { get; set; }

/// <summary>
/// 获得/设置 值为 null 时是否使用第一个选项作为默认值
/// <para>Gets or sets a value indicating whether the "active" state should be used when the associated value is null.</para>
/// 获得/设置 值为 null 时是否使用第一个选项或者标记为 active 的候选项作为默认值
/// <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>
/// </summary>
[Parameter]
public bool IsUseActiveWhenValueIsNull { get; set; }
[Obsolete("已弃用,请使用 IsUseDefaultItemWhenValueIsNull 参数代替;Deprecated, use the IsUseDefaultItemWhenValueIsNull parameter instead")]
[ExcludeFromCodeCoverage]
public bool IsUseActiveWhenValueIsNull
{
get => IsUseDefaultItemWhenValueIsNull;
set => IsUseDefaultItemWhenValueIsNull = value;
}

/// <summary>
/// 获得/设置 值为 null 时是否使用第一个选项或者标记为 active 的候选项作为默认值
/// <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>
/// </summary>
[Parameter]
public bool IsUseDefaultItemWhenValueIsNull { get; set; }

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

return IsUseActiveWhenValueIsNull && !IsVirtualize
return IsUseDefaultItemWhenValueIsNull && !IsVirtualize
? SetSelectedItemState(GetItemByRows())
: null;
}
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTest/Components/SelectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task IsUseActiveWhenValueNull_Ok()
new("1", "Test1"),
new("2", "Test2") { Active = true }
});
pb.Add(a => a.IsUseActiveWhenValueIsNull, true);
pb.Add(a => a.IsUseDefaultItemWhenValueIsNull, true);
pb.Add(a => a.OnSelectedItemChanged, item =>
{
selectedValue = item.Value;
Expand Down
Loading