Skip to content

Commit

Permalink
Merge pull request #599 from pcfist/datatable-measureoverride-crash-fix
Browse files Browse the repository at this point in the history
Fix DataTable crash on resize when columns don't fit
  • Loading branch information
michael-hawker authored Feb 21, 2025
2 parents 833164a + 5f037b6 commit f664523
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/DataTable/src/DataTable/DataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ 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.
column.Measure(new Size(Math.Max(availableSize.Width - fixedWidth - autoSized, 0), 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 f664523

Please sign in to comment.