Skip to content

fix: GenerateHeaderOption.Sticky with ResizableColumns doesn't work as expected in FluentDataGrid #3888

@ghood97

Description

@ghood97

🐛 Bug Report

When using FluentDataGrid with GenerateHeaderOption.Sticky and ResizableColumns=true, the header does not stick. Without ResizableColumns=true, the sticky header works as expected.

💻 Repro or Code Sample

I have set up a minimal reproducible sample here: https://github.com/ghood97/FluentDataGridTest

The component with the data grid is at Components/Pages/Home.razor. The solution is ready to run so just need to clone and open in VS. I have also included the component code below:

@page "/"
@using Microsoft.FluentUI.AspNetCore.Components

<FluentDataGrid TGridItem="GridRowObject"
                Items="@AllItems.AsQueryable()"
                ResizableColumns
                GenerateHeader="GenerateHeaderOption.Sticky">
    <ChildContent>
        <PropertyColumn TGridItem="GridRowObject"
                        TProp="string"
                        Sortable="true"
                        Title="Name"
                        Property="i => i.Name"
                        Tooltip />
        <PropertyColumn TGridItem="GridRowObject"
                        TProp="string"
                        Sortable="true"
                        Title="Value"
                        Property="i => i.Value"
                        Tooltip />
    </ChildContent>
</FluentDataGrid>

@code {
    private List<GridRowObject> AllItems = [];

    protected override void OnInitialized()
    {
        for (int i = 0; i < 100; i++)
        {
            AllItems.Add(new GridRowObject
                {
                    Name = $"Instance {i}",
                    Value = $"Value {i}"
                });
        }
    }


    class GridRowObject
    {
        public required string Name { get; set; }

        public required string Value { get; set; }
    }
}

🤔 Expected Behavior

The header row should be sticky and should remain at the top of the page or container instead of scrolling out of view.

😯 Current Behavior

The header row scrolls out of view as if the Sticky option is not set. As soon as I set ResizableColumns=false, it works as expected.

💁 Possible Solution

🔦 Context

I am trying to present a FluentDataGrid with a sticky header and resizable columns among other options. However, in the repo linked above, no other options are added.

🌍 Your Environment

  • OS & Device: Windows 11
  • Browser: Microsoft Edge
  • .NET and Fluent UI Blazor library Version: 4.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions