-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[DataGrid] Fix column spanning jump on scroll #17759
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,16 +431,30 @@ export function getFirstNonSpannedColumnToRender({ | |
visibleRows: GridRowEntry[]; | ||
}) { | ||
let firstNonSpannedColumnToRender = firstColumnToRender; | ||
for (let i = firstRowToRender; i < lastRowToRender; i += 1) { | ||
const row = visibleRows[i]; | ||
if (row) { | ||
const rowId = visibleRows[i].id; | ||
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo( | ||
rowId, | ||
firstColumnToRender, | ||
); | ||
if (cellColSpanInfo && cellColSpanInfo.spannedByColSpan) { | ||
firstNonSpannedColumnToRender = cellColSpanInfo.leftVisibleCellIndex; | ||
let foundStableColumn = false; | ||
|
||
// Keep checking columns until we find one that's not spanned in any visible row | ||
while (!foundStableColumn && firstNonSpannedColumnToRender >= 0) { | ||
foundStableColumn = true; | ||
|
||
for (let i = firstRowToRender; i < lastRowToRender; i += 1) { | ||
const row = visibleRows[i]; | ||
if (row) { | ||
const rowId = visibleRows[i].id; | ||
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo( | ||
rowId, | ||
firstNonSpannedColumnToRender, | ||
); | ||
|
||
if ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at certain scroll positions it seems that this code is called in intervals (don't think it is because of the changes made in this PR) Screen.Recording.2025-05-09.at.14.42.59.movThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! Opened a separate PR for this one: #17779 |
||
cellColSpanInfo && | ||
cellColSpanInfo.spannedByColSpan && | ||
cellColSpanInfo.leftVisibleCellIndex < firstNonSpannedColumnToRender | ||
) { | ||
firstNonSpannedColumnToRender = cellColSpanInfo.leftVisibleCellIndex; | ||
foundStableColumn = false; | ||
break; // Check the new column index against the visible rows, because it might be spanned | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC
firstNonSpannedColumnToRender
is always>= 0