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
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/AutoFill/AutoFill.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
else
{
<Virtualize ItemSize="RowHeight" OverscanCount="OverscanCount" ItemsProvider="LoadItems"
Placeholder="RenderPlaceHolderRow" ItemContent="RenderRow" @ref="_virtualizeElement">
Placeholder="RenderPlaceholderRow" ItemContent="RenderRow" @ref="_virtualizeElement">
</Virtualize>
}
</div>
Expand Down Expand Up @@ -68,7 +68,7 @@
}
</div>;

RenderFragment<PlaceholderContext> RenderPlaceHolderRow => context =>
RenderFragment<PlaceholderContext> RenderPlaceholderRow => context =>
@<div class="dropdown-item" style="@PlaceHolderStyleString">
<div class="is-ph"></div>
</div>;
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public partial class AutoFill<TValue>
public bool IsVirtualize { get; set; }

/// <summary>
/// Gets or sets the row height for virtual scrolling. Default is 33.
/// Gets or sets the row height for virtual scrolling. Default is 50f.
/// </summary>
/// <remarks>Effective when <see cref="IsVirtualize"/> is set to true.</remarks>
[Parameter]
Expand Down Expand Up @@ -160,7 +160,7 @@ public partial class AutoFill<TValue>
.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;

Expand Down
19 changes: 9 additions & 10 deletions src/BootstrapBlazor/Components/Table/Table.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@namespace BootstrapBlazor.Components
@using Microsoft.AspNetCore.Components.Web.Virtualization
@typeparam TItem
@inherits BootstrapModuleComponentBase
@attribute [BootstrapModuleAutoLoader(JSObjectReference = true)]
Expand Down Expand Up @@ -368,18 +369,16 @@
{
@if (Items != null)
{
<Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize @ref="VirtualizeElement"
ItemSize="RowHeight" OverscanCount="10" Items="@Items.ToList()" ChildContent="RenderRow" />
<Virtualize @ref="VirtualizeElement"
ItemSize="RowHeight" OverscanCount="10" Items="@Items.ToList()" ChildContent="RenderRow">
</Virtualize>
}
else
{
<Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize @ref="VirtualizeElement"
ItemSize="RowHeight" OverscanCount="10"
ItemsProvider="LoadItems" ItemContent="RenderRow">
<Placeholder>
@RenderPlaceHolderRow
</Placeholder>
</Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize>
<Virtualize @ref="VirtualizeElement"
ItemSize="RowHeight" OverscanCount="10" Placeholder="RenderPlaceholderRow"
ItemsProvider="LoadItems" ItemContent="RenderRow">
</Virtualize>
}
}
else
Expand Down Expand Up @@ -808,7 +807,7 @@
}
</DynamicElement>;

RenderFragment RenderPlaceHolderRow =>
RenderFragment<PlaceholderContext> RenderPlaceholderRow => context =>
@<tr>
@if (IsMultipleSelect)
{
Expand Down
30 changes: 30 additions & 0 deletions test/UnitTest/Components/AutoFillTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IStringLocalizer<Foo>>();
var cut = Context.RenderComponent<AutoFill<Foo>>(pb =>
{
pb.Add(a => a.OnQueryAsync, option =>
{
var items = Foo.GenerateFoo(localizer, 80).Skip(option.StartIndex).Take(5);
var ret = new QueryData<Foo>()
{
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("<div class=\"dropdown-item\"><div class=\"is-ph\"></div></div>");

cut.SetParametersAndRender(pb =>
{
pb.Add(a => a.RowHeight, 35f);
});
cut.Contains("<div class=\"dropdown-item\" style=\"height: 35px;\"><div class=\"is-ph\"></div></div>");
}

[Fact]
public async Task IsVirtualize_OnQueryAsync_Clearable_Ok()
{
Expand All @@ -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, () =>
{
Expand Down