Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: UI does not leave Loading animation if result has 0 items in FluentDataGrid #1437

Closed
dejaypiii opened this issue Feb 3, 2024 · 1 comment

Comments

@dejaypiii
Copy link

dejaypiii commented Feb 3, 2024

馃悰 Bug Report

I tried the new Loading state of the FluentDataGrid and experienced some unexpected behaviors.
If I fetch data and get 0 items back, the loading animation keeps on spinning instead of displaying the EmptyContent fragment.
Another one was that I don't get the loading animation if I have already fetched some items and trigger additonal remote data fetches afterwards.

馃捇 Repro or Code Sample


@page "/DataGrid"

<PageTitle>Loading state doesn't exit.</PageTitle>

<FluentDataGrid ItemsProvider="LoadData"
                TGridItem="GridItem" Loading="true">
    <PropertyColumn Property="@(x => x.Value)"></PropertyColumn>
</FluentDataGrid>

@code
{
    private ValueTask<GridItemsProviderResult<GridItem>> LoadData(GridItemsProviderRequest<GridItem> request)
    {
        return ValueTask.FromResult(GridItemsProviderResult.From(new GridItem[0], 0));
    }

    record GridItem(string Value);

}

馃 Expected Behavior

After the remote data got fetched and the result contains 0 items, the data grid should leave the loading state and render the EmptyContent fragment.

馃槸 Current Behavior

Because the item count of the result isn't greater than 0 the data grid doesn't set loading to false and keeps displaying the LoadingContent fragment.

馃拋 Possible Solution

My naive guess would be that don't checking the _ariaBodyRowCount for Loading state features would fix this issue.
For example in FluentDataGrid.razor:33 and FluentDataGrid.razor.cs:371.
But then also the check in FluentDataGrid.razor.cs:375 must be removed because otherwise no rendering of the EmptyContent will occure.
But maybe I miss something because these got added intentionally to fix some LoadingContent issues in c3933e2

// Please let us know if you'd be willing to contribute the fix; we'd be happy to work with you
Yes

馃敠 Context

I used BlazorWasm.
My use case is a list page with pagination that fetches remote data for the current page to display.
A result with zero items is a valid result which should tell the user that there is no data here.

Also if I issue a filter/search or navigate between pages, it may be benefical to display the LoadingContent again, which doesn't happen because of already displayed items, even if the Grid state is set to Loading=true again.

馃實 Your Environment

  • OS & Device: [e.g. MacOS, iOS, Windows, Linux] on [iPhone 7, PC]
  • Browser Edge, Chrome, Firefox
  • .NET and FAST Version .NET8 and FAST 4.4
@vnbaaij
Copy link
Collaborator

vnbaaij commented Feb 5, 2024

With the fixes going in for the DataGrid, this is now solved (partialy) as well. Change the LoadData to:

private async ValueTask<GridItemsProviderResult<GridItem>> LoadData(GridItemsProviderRequest<GridItem> request)
{
    await Task.Delay(3000);
    return GridItemsProviderResult.From(new GridItem[0], 0);
}

Will give you:
issue-#1437

Another one was that I don't get the loading animation if I have already fetched some items and trigger additonal remote data fetches afterwards.

We have not designed this to woark that way. If you want to submit a PR for that, that would be great!

vnbaaij added a commit that referenced this issue Feb 5, 2024
@vnbaaij vnbaaij closed this as completed in 6d66226 Feb 6, 2024
vnbaaij added a commit that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants