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.3k stars 305 forks source link

fix: OnRowFocus in FluentDataGrid not triggered #2061

Closed oseegers1977 closed 2 weeks ago

oseegers1977 commented 2 weeks ago

🐛 Bug Report

I started a default Blazor Web App project (.NET 8.0) in Visual Studio 2022. I followed the page FluentUI Code Setup for manually setup the component Library

What I want is when I Click a row in a Grid that I can navigate/show a detailpage. The OnRowFocus Callback is never triggered.

💻 Repro or Code Sample

@page "/"

<PageTitle>Home</PageTitle>
<FluentDataGrid Virtualize="false" ItemSize="120" OnRowFocus="HandleRowClick" TGridItem="Person" ItemsProvider="PeopleData">
    <PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
    <PropertyColumn Property="@(p => p.Name)" Sortable="true" />
    <PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
</FluentDataGrid>

@code{
    record Person(int PersonId, string Name, DateOnly BirthDate);

    List<Person> people =
    [
        new Person(10895, "Jean Martin", new DateOnly(1985, 3, 16)),
        new Person(10944, "António Langa", new DateOnly(1991, 12, 1)),
        new Person(11203, "Julie Smith", new DateOnly(1958, 10, 10)),
        new Person(11205, "Nur Sari", new DateOnly(1922, 4, 27)),
        new Person(11898, "Jose Hernandez", new DateOnly(2011, 5, 3)),
        new Person(12130, "Kenji Sato", new DateOnly(2004, 1, 9))
    ];

    GridItemsProvider<Person>? PeopleData;

    protected override Task OnInitializedAsync()
    {
        PeopleData = async req => GridItemsProviderResult.From(
            items: people,
            totalItemCount: people.Count());
        return Task.CompletedTask;
    }
    private void HandleRowClick(FluentDataGridRow<Person> obj)
    {
        Console.WriteLine("Clicked!!");
    }
}

🤔 Expected Behavior

Console Writeline with message Clicked!

😯 Current Behavior

OnRowFocus not triggered image

🔦 Context

After selecting a row I want to load an another page with detailed information

🌍 Your Environment

vnbaaij commented 2 weeks ago

If you're using the default settings, you are most probably using SSR (static server rendering). For the DataGrid to work, interactivity is needed.