Skip to content

Commit dc8741a

Browse files
committed
Fix DataTable crash on resize when columns don't fit.
1 parent b71dbf1 commit dc8741a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

components/DataTable/src/DataTable/DataTable.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ protected override Size MeasureOverride(Size availableSize)
9393
// then invalidate the child arranges [don't re-measure and cause loop]...)
9494

9595
// For now, we'll just use the header content as a guideline to see if things work.
96-
column.Measure(new Size(availableSize.Width - fixedWidth - autoSized, availableSize.Height));
96+
97+
// Avoid negative values when columns don't fit `availableSize`. Otherwise the `Size` constructor will throw.
98+
double width = availableSize.Width - fixedWidth - autoSized;
99+
if (width < 0)
100+
width = 0;
101+
column.Measure(new Size(width, availableSize.Height));
97102

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

0 commit comments

Comments
 (0)