Skip to content

Commit

Permalink
Fix DataTable crash on resize when columns don't fit.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcfist committed Nov 16, 2024
1 parent eba3625 commit 08c2fbf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/DataTable/src/DataTable/DataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ protected override Size MeasureOverride(Size availableSize)
// then invalidate the child arranges [don't re-measure and cause loop]...)

// For now, we'll just use the header content as a guideline to see if things work.
column.Measure(new Size(availableSize.Width - fixedWidth - autoSized, availableSize.Height));

// Avoid negative values when columns don't fit `availableSize`. Otherwise the `Size` constructor will throw.
double width = availableSize.Width - fixedWidth - autoSized;
if (width < 0)
width = 0;
column.Measure(new Size(width, availableSize.Height));

// Keep track of already 'allotted' space, use either the maximum child size (if we know it) or the header content
autoSized += Math.Max(column.DesiredSize.Width, column.MaxChildDesiredWidth);
Expand Down

0 comments on commit 08c2fbf

Please sign in to comment.