Conversation
- Update verified files - Set table-layout:fixed when in DisplayMode table
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.8%
|
There was a problem hiding this comment.
Pull request overview
Updates FluentDataGrid header/layout behavior to address Width-related sizing issues (per #4582), especially around header content sizing and table-mode column sizing.
Changes:
- Removes inline
width: 100%styling from header title containers so header widths can update correctly. - Adjusts sortable header button styling via DataGrid cell CSS (including width/min-width behavior).
- Forces
table-layout: fixedinDisplayMode.Tableto make column widths behave more predictably; updates verified rendering snapshots accordingly.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Core/Components/DataGrid/Columns/ColumnBase.razor | Removes inline width styling from header content and sort button rendering paths. |
| src/Core/Components/DataGrid/FluentDataGridCell.razor.css | Updates .col-sort-button sizing rules and fixes CSS formatting in justify variants. |
| src/Core/Components/DataGrid/FluentDataGrid.razor.cs | Adds table-layout: fixed for table display mode. |
| tests/Core/Components/DataGrid/*.verified.razor.html | Updates snapshots to reflect removal of inline width: 100% on .col-title. |
Comments suppressed due to low confidence (1)
src/Core/Components/DataGrid/FluentDataGridCell.razor.css:68
.col-sort-buttonis declared twice back-to-back, with the second rule only repeatingoverflow: hidden;. This is redundant and makes future edits error-prone; please merge these into a single selector (or remove the duplicate) so the source of truth is in one place.
.fluent-data-grid .col-sort-button {
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
min-width: 75px;
}
.fluent-data-grid .col-sort-button {
overflow: hidden;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else | ||
| { | ||
| <div class="col-title" style="width: 100%;"> | ||
| <div class="col-title"> |
There was a problem hiding this comment.
The new <div class="col-title"> line is indented with tabs while surrounding component .razor files use spaces (e.g., src/Core/Components/SortableList/FluentSortableList.razor). Please convert this block’s indentation to spaces to keep formatting consistent.
| <div class="col-title"> | |
| <div class="col-title"> |
| @@ -69,19 +70,23 @@ | |||
| .fluent-data-grid .col-justify-start .col-sort-button { | |||
| justify-content: start; | |||
| overflow: hidden; | |||
| opacity: 1 | |||
| opacity: 1; | |||
| min-width: 75px; | |||
| } | |||
|
|
|||
| .fluent-data-grid .col-justify-center .col-sort-button { | |||
| justify-content: center; | |||
| overflow: hidden; | |||
| opacity: 1 | |||
| opacity: 1; | |||
| min-width: 75px; | |||
| } | |||
There was a problem hiding this comment.
The new hard-coded min-width: 75px on .col-sort-button (and repeated again in each justify-specific rule) can prevent very narrow column widths from being respected in layouts where header content contributes to intrinsic sizing (e.g., auto/fr sizing). Consider using min-width: 0 (to explicitly override the FluentButton host default) and/or deriving any minimum from the column’s MinWidth behavior, and define it once instead of repeating it in each justify rule.
| @@ -120,7 +120,7 @@ | |||
| { | |||
|
|
|||
| // <FluentButton Appearance="ButtonAppearance.Subtle" Class="col-sort-button" Style="@($"width: calc(100% - {wdelta});")" @onclick="@(() => Grid.SortByColumnAsync(this))" aria-label="@tooltip" title="@tooltip" @oncontextmenu="@(() => Grid.RemoveSortByColumnAsync(this))"> | |||
There was a problem hiding this comment.
There’s a commented-out <FluentButton ... Style=@($"width: calc(100% - {wdelta});") ...> line immediately above the active implementation. Since the implementation changed, this comment is now stale and can confuse future maintenance; please remove it (or replace it with an explanatory comment that matches the current sizing approach).
| // <FluentButton Appearance="ButtonAppearance.Subtle" Class="col-sort-button" Style="@($"width: calc(100% - {wdelta});")" @onclick="@(() => Grid.SortByColumnAsync(this))" aria-label="@tooltip" title="@tooltip" @oncontextmenu="@(() => Grid.RemoveSortByColumnAsync(this))"> |
|
I'm going to review and test on monday. Currently I'm not at home |
Fixes issues mentioned in #4582
Header not applying width twice
Yup, the style=100% is the culprit here. I'll remove it and verify.
Additional space when sortable is enabled
The optimal min-width is arbitrary and depends mostly on what title you are using. With the word year and applying a sort (so the arrow gets shown (with its own margin/padding)) the minimal with could be brought down to around 80 pixels. I'll set the min-width to 75px in the CSS.
There was also a calc that subtracted 20px from the width. I'll remove that also
Wrong sizing
When switching to table layout, the table uses the default table-layout: auto, the column width is being determined by the content of the entire column (not just the ). The browser will expand the column to fit it's content. I'll change it so that it uses table-layout: fixed in that mode. It already sets it to that when resizing is enabled anyway