Skip to content

fix: Loading value is now ignored in DataGrid when there is an item provider #2998

@adamint

Description

@adamint

🐛 Bug Report

There has been a regression in fluentui-blazor's DataGrid component recently (first noticed in dotnet/aspire#6834) - Loading works as expected when the Items parameter is provided. However, if instead you set ItemsProvider, if no items are returned in the item provider EmptyContent will be rendered even if Loading is set to true

💻 Repro or Code Sample

<div style="height: 434px; overflow:auto;" tabindex="-1">
    <FluentDataGrid style="height: 100%;" Loading="true" ItemsProvider="@foodRecallProvider" Virtualize="true" ItemSize="46" GenerateHeader="GenerateHeaderOption.Sticky" TGridItem="string" >
        <PropertyColumn Title="ID" Property="@(c => c)" />
    </FluentDataGrid>
</div>

<p>Total: <strong>@numResults results found</strong></p>

@code {
    GridItemsProvider<string> foodRecallProvider = default!;
    int? numResults;

    protected override async Task OnInitializedAsync()
    {
        foodRecallProvider = async req =>
        {   
            return GridItemsProviderResult.From<string>(
                items: [],
                totalItemCount: 0);
        };

        // Display the number of results just for information. This is completely separate from the grid.
        numResults = 1;
    }
}

🤔 Expected Behavior

If Loading is set to true, even if the items provider has returned successfully with 0 items, LoadingContent should be rendered instead of EmptyContent.

😯 Current Behavior

EmptyContent is rendered.

💁 Possible Solution

🔦 Context

🌍 Your Environment

  • OS & Device: [e.g. MacOS, iOS, Windows, Linux] on [iPhone 7, PC]
  • Browser [e.g. Microsoft Edge, Google Chrome, Apple Safari, Mozilla FireFox]
  • .NET and Fluent UI Blazor library Version [e.g. 8.0.2 and 4.4.1]

Fluent UI 4.10.4, chrome

Metadata

Metadata

Assignees

Labels

bugA bugcommunity:contributionIssue will/can be addressed by community contribution

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions