Fix null reference in DataGrid layout rounding scroll logic#243
Merged
Conversation
MrJul
approved these changes
Jun 23, 2026
MrJul
left a comment
Member
There was a problem hiding this comment.
The changes make sense. The returned values from GetPrevious/NextVisibleScrollingColumn could definitely be null.
This was referenced Jun 23, 2026
This was referenced Jun 29, 2026
fuzzzerd
pushed a commit
to fuzzzerd/SharpFM
that referenced
this pull request
Jun 30, 2026
Updated [Avalonia](https://github.com/AvaloniaUI/Avalonia/) from 12.0.4 to 12.0.5. <details> <summary>Release notes</summary> _Sourced from [Avalonia's releases](https://github.com/AvaloniaUI/Avalonia//releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/AvaloniaUI/Avalonia//commits). </details> Updated [Avalonia.Controls.DataGrid](https://github.com/AvaloniaUI/Avalonia.Controls.DataGrid) from 12.0.0 to 12.0.1. <details> <summary>Release notes</summary> _Sourced from [Avalonia.Controls.DataGrid's releases](https://github.com/AvaloniaUI/Avalonia.Controls.DataGrid/releases)._ ## 12.0.1 ## What's Changed * Update DataGridColumn sort binding checks by @rabbitism in AvaloniaUI/Avalonia.Controls.DataGrid#230 * Fix template column edit commit and context menu regression in DataGrid_LostFocus by @kdurane in AvaloniaUI/Avalonia.Controls.DataGrid#235 * Fix null reference in DataGrid layout rounding scroll logic by @zrt2399 in AvaloniaUI/Avalonia.Controls.DataGrid#243 * Fix ScrollBar not reacting to ScrollViewer.AllowAutoHide property changes by @zrt2399 in AvaloniaUI/Avalonia.Controls.DataGrid#241 * Update Avalonia to 12.0.5 by @MrJul in AvaloniaUI/Avalonia.Controls.DataGrid#246 **Full Changelog**: AvaloniaUI/Avalonia.Controls.DataGrid@12.0.0...12.0.1 Commits viewable in [compare view](https://github.com/AvaloniaUI/Avalonia.Controls.DataGrid/commits/12.0.1). </details> Updated [Avalonia.Desktop](https://github.com/AvaloniaUI/Avalonia/) from 12.0.4 to 12.0.5. <details> <summary>Release notes</summary> _Sourced from [Avalonia.Desktop's releases](https://github.com/AvaloniaUI/Avalonia//releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/AvaloniaUI/Avalonia//commits). </details> Updated [Avalonia.Fonts.Inter](https://github.com/AvaloniaUI/Avalonia/) from 12.0.4 to 12.0.5. <details> <summary>Release notes</summary> _Sourced from [Avalonia.Fonts.Inter's releases](https://github.com/AvaloniaUI/Avalonia//releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/AvaloniaUI/Avalonia//commits). </details> Updated [Avalonia.Themes.Fluent](https://github.com/AvaloniaUI/Avalonia/) from 12.0.4 to 12.0.5. <details> <summary>Release notes</summary> _Sourced from [Avalonia.Themes.Fluent's releases](https://github.com/AvaloniaUI/Avalonia//releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/AvaloniaUI/Avalonia//commits). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix a layout-rounding edge case in DataGrid.ComputeDisplayedColumns.
When UseLayoutRounding is enabled, column layout can differ slightly from the logical ActualWidth-based scrolling calculations due to pixel rounding. After resizing and maximizing the window, this can leave a small positive horizontal offset even though the first displayed scrolling column is already the first visible scrolling column.
In that state, GetPreviousVisibleScrollingColumn(...) correctly returns null, because there is no previous scrolling column. The existing code assumed a previous column must exist whenever _horizontalOffset > 0, which could lead to a null dereference.
This change handles that boundary condition explicitly. If no previous visible scrolling column exists, the grid clamps the horizontal offset state back to zero and marks the displayed column state as invalidated. Otherwise, it preserves the existing behavior for partially scrolling in the previous column.
This prevents a crash while keeping the scroll/display state consistent with the actual leftmost scrolling column.