Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DataTable crash on resize when columns don't fit #599

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/DataTable/src/DataTable/DataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ 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;
width = Math.Max(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