Skip to content

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

Closed

Description

@adamint

🐛 Bug Report

There has been a regression in fluentui-blazor's DataGrid component recently (first noticed in microsoft/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

Activity

  1. added
    triage
    on Dec 2, 2024
  2. added
    bug
    community:contribution
    and removed
    triage
    on Dec 2, 2024
  3. added this to the v4.11 milestone on Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugcommunity:contribution

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions