fluentui-blazor: fix: Resizable columns do not work correctly with dynamic columns in FluentDataGrid
๐ Bug Report
A FluentDataGrid with ResizableColumns=โtrueโ and utilizing Dynamic Columns doesnโt work correctly.
๐ป Repro or Code Sample
@page "/test"
<p>
Show:
<FluentCheckbox @bind-Value="showName">Name</FluentCheckbox>
<FluentCheckbox @bind-Value="showBirthDate">Birth date</FluentCheckbox>
</p>
<FluentDataGrid Items="@people.AsQueryable()" GridTemplateColumns="0.5fr 1fr 1fr" style="width: 500px;" ResizableColumns="true">
<PropertyColumn Title="ID" Property="@(c => c.PersonId)" Sortable="true" />
@if (showName)
{
<TemplateColumn Title="Name">
<strong>@context.LastName</strong>, @context.FirstName
</TemplateColumn>
}
<PropertyColumn Title="Last name" Property="@(c => c.LastName)" Sortable="true" />
<PropertyColumn Title="First name" Property="@(c => c.FirstName)" Sortable="true" />
<TemplateColumn Title="Some junk">
The Microsoft.FluentUI.AspNetCore.Components package provides a set of Blazor components. Some of the components are wrappers around Microsoft's official Fluent UI Web Components. Others are components that leverage the Fluent Design System or make it easier to work with Fluent. To get up and running with the Microsoft.FluentUI.AspNetCore.Components library, see the 'Getting Started'' section below.
</TemplateColumn>
@if (showBirthDate)
{
<PropertyColumn Title="Birth date" Property="@(c => c.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
}
<TemplateColumn Title="Some junk2">
The Microsoft.FluentUI.AspNetCore.Components package provides a set of Blazor components. Some of the components are wrappers around Microsoft's official Fluent UI Web Components. Others are components that leverage the Fluent Design System or make it easier to work with Fluent. To get up and running with the Microsoft.FluentUI.AspNetCore.Components library, see the 'Getting Started'' section below.
</TemplateColumn>
</FluentDataGrid>
@code {
bool showName = true;
bool showBirthDate = false;
public class Person
{
public int PersonId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime BirthDate { get; set; }
}
private Person[] people = new Person[]
{
new Person { PersonId = 1, FirstName = "John", LastName = "Doe", BirthDate = new DateTime(1980, 1, 1) },
new Person { PersonId = 2, FirstName = "Jane", LastName = "Doe", BirthDate = new DateTime(1985, 2, 2) },
new Person { PersonId = 3, FirstName = "Sam", LastName = "Smith", BirthDate = new DateTime(1990, 3, 3) },
};
}
๐ค Expected Behavior
I would expect the contents of the FluentDataGrid to be rendered correctly, and for resizable columns to work correctly. And to continue to work as dynamic columns are shown/hidden.
๐ฏ Current Behavior
The grid renders artifacts and the resize behavior becomes erratic. See attached screen recording.
๐ Possible Solution
๐ฆ Context
๐ Your Environment
- MacOS
- Chrome (arm64)
- .NET 8.0.101
https://github.com/microsoft/fluentui-blazor/assets/3911628/f2c3bd3a-9301-4b27-9a94-dcc1397bb0dc
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
I managed to make it a little beter by โresettingโ the column widths on the first resize action. Now if can just trigger that when a column gets added/removedโฆ