diff --git a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor index 796198fd49e..43dd1bdd884 100644 --- a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor +++ b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor @@ -34,7 +34,7 @@ else { + Placeholder="RenderPlaceholderRow" ItemContent="RenderRow" @ref="_virtualizeElement"> } @@ -68,7 +68,7 @@ } ; - RenderFragment RenderPlaceHolderRow => context => + RenderFragment RenderPlaceholderRow => context => @; diff --git a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs index dcb7178e0d0..cc9cbeca453 100644 --- a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs +++ b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs @@ -99,7 +99,7 @@ public partial class AutoFill public bool IsVirtualize { get; set; } /// - /// Gets or sets the row height for virtual scrolling. Default is 33. + /// Gets or sets the row height for virtual scrolling. Default is 50f. /// /// Effective when is set to true. [Parameter] @@ -160,7 +160,7 @@ public partial class AutoFill .AddClass($"text-danger", IsValid.HasValue && !IsValid.Value) .Build(); - private string? PlaceHolderStyleString => RowHeight > 50f + private string? PlaceHolderStyleString => RowHeight != 50f ? CssBuilder.Default().AddStyle("height", $"{RowHeight}px").Build() : null; diff --git a/src/BootstrapBlazor/Components/Table/Table.razor b/src/BootstrapBlazor/Components/Table/Table.razor index 178c5211dda..e0a925d96f7 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor +++ b/src/BootstrapBlazor/Components/Table/Table.razor @@ -1,4 +1,5 @@ @namespace BootstrapBlazor.Components +@using Microsoft.AspNetCore.Components.Web.Virtualization @typeparam TItem @inherits BootstrapModuleComponentBase @attribute [BootstrapModuleAutoLoader(JSObjectReference = true)] @@ -368,18 +369,16 @@ { @if (Items != null) { - + + } else { - - - @RenderPlaceHolderRow - - + + } } else @@ -808,7 +807,7 @@ } ; - RenderFragment RenderPlaceHolderRow => + RenderFragment RenderPlaceholderRow => context => @ @if (IsMultipleSelect) { diff --git a/test/UnitTest/Components/AutoFillTest.cs b/test/UnitTest/Components/AutoFillTest.cs index a61f52d2ee4..6cb6533a02d 100644 --- a/test/UnitTest/Components/AutoFillTest.cs +++ b/test/UnitTest/Components/AutoFillTest.cs @@ -349,6 +349,35 @@ public async Task IsVirtualize_Items_Clearable_Ok() Assert.Null(input.NodeValue); } + [Fact] + public void Placeholder_Ok() + { + var localizer = Context.Services.GetRequiredService>(); + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.OnQueryAsync, option => + { + var items = Foo.GenerateFoo(localizer, 80).Skip(option.StartIndex).Take(5); + var ret = new QueryData() + { + Items = items, + TotalCount = 80 + }; + return Task.FromResult(ret); + }); + pb.Add(a => a.IsVirtualize, true); + pb.Add(a => a.RowHeight, 50f); + pb.Add(a => a.OnGetDisplayText, f => f?.Name); + }); + cut.Contains("
"); + + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.RowHeight, 35f); + }); + cut.Contains("
"); + } + [Fact] public async Task IsVirtualize_OnQueryAsync_Clearable_Ok() { @@ -375,6 +404,7 @@ public async Task IsVirtualize_OnQueryAsync_Clearable_Ok() pb.Add(a => a.Value, items[0]); pb.Add(a => a.IsVirtualize, true); pb.Add(a => a.IsClearable, true); + pb.Add(a => a.RowHeight, 35f); pb.Add(a => a.OnGetDisplayText, f => f?.Name); pb.Add(a => a.OnClearAsync, () => {