microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.65k stars 350 forks source link

fix: [FluentDataGrid data not loading] after ShowPanelAsync HandlePanel] #2486

Closed ajitanil closed 3 weeks ago

ajitanil commented 1 month ago

🐛 Bug Report

Issue: On PageLoad- Users are getting loaded. But after opening the popup - on Save/Cancel -> User Grid not loading users again.

💻 Repro or Code Sample

//Fluent Data Grid <FluentDataGrid Loading="true" ItemsProvider="usersProvider" Virtualize="true" ItemSize="46" GenerateHeader="GenerateHeaderOption.Sticky" GridTemplateColumns="1fr 1fr 1fr 1fr" TGridItem="OrganizationUsersOutputAPIModel">

Invite User

//On Page Load - Load Users private async Task LoadUsers() { PageMetadata pagemetadata = new PageMetadata(); usersProvider = async req => {

    users = await UMRESTClientService.GetPageListOrganizationUsers(pagemetadata, req.StartIndex, req.Count);

    //Simulate a slow data retrieval process
    if (req.Count is null)
    {
        await Task.Delay(5);
    }
    var result = GridItemsProviderResult.From(
        items: users,
        totalItemCount: pagemetadata.TotalCount);

    return result;
};

// Display the number of results just for information. This is completely separate from the grid.
numResults = pagemetadata.TotalCount; //(await Http.GetFromJsonAsync<FoodRecallQueryResult>("https://api.fda.gov/food/enforcement.json"))!.Meta.Results.Total;

}

//For opening the panel private async void OpenPanelRight() { userModel = new(); _dialog = await DialogService.ShowPanelAsync(userModel, new DialogParameters() { Content = userModel, Alignment = HorizontalAlignment.Right, Title = $"Invite User", PrimaryAction = string.Empty, SecondaryAction = string.Empty

    });
DialogResult result = await _dialog.Result;
HandlePanel(result);

}

//Handle Function private async void HandlePanel(DialogResult result) { await LoadUsers(); if (result.Cancelled) { Console.WriteLine($"Panel cancelled"); return; }

if (result.Data is not null)
{
    Console.WriteLine($"Data Saved");
}   

}

🤔 Expected Behavior

  1. List of Users to be displayed in Grid
  2. On click of button - Panel should be opened on the right
  3. On Save/Cancel Same page with List of Users should be displayed

😯 Current Behavior

  1. List of Users to be displayed in Grid - WORKING AS EXPECTED
  2. On click of button - Panel should be opened on the right - WORKING AS EXPECTED
  3. On Save/Cancel Same page with List of Users should be displayed - NOT WORKING
  4. GRID IS NOT LOADING WITH USER DATA. IT IS ONLY SHOWING LOADING...

💁 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]

OS: WINDOWS BROWSER: CHROME,EDGE FLUENT UI VERSION 4.6.1 .NET 8

vnbaaij commented 1 month ago

Please add reproduction code we can run. Add a project (zip file) or link to a GitHub repository. We can not reproduce with the example you posted and we don't have capacity to just go and try to get your issue to appear.

Help us to help you.

PS will take a bit of time due to vacation period.

vnbaaij commented 1 month ago

Also, we only support our latest released packages. So try upgrading to that version first.

ajitanil commented 1 month ago

Thank you for your response @vnbaaij As suggested will upgrade to the latest version and share the code in a zip file / Git repo link

ajitanil commented 1 month ago

Please find the Git repo link for the code https://github.com/ajitanil/fluentui.git

Also, please check the screenshots for a better understanding of the issue. /users page is in client project

  1. User Index Page on Load Index

  2. Click - Invite User Button -> Opens panel OpenPanel

  3. On Cancel/Save -> Index page still shows Loading.. PanelClose

ajitanil commented 1 month ago

@vnbaaij Please let me know if you are able to access the git repo https://github.com/ajitanil/fluentui.git

vnbaaij commented 3 weeks ago

This is not an issue in the library but in your code. You need to remove the Loading="true" part. See https://www.fluentui-blazor.net/DataGrid#intermittentloading for an example on how to add a loading indicator intermittently