Conversation
17d0bf2 to
f378e2e
Compare
| readonly accessibilityHeight: number; | ||
|
|
||
| readonly freezeColumns: number; | ||
| readonly freezeColumns: number | [left: number, right: number]; |
There was a problem hiding this comment.
For a stricter type definition, I suggest using the readonly flag here.
| readonly freezeColumns: number | [left: number, right: number]; | |
| readonly freezeColumns: number | readonly [left: number, right: number]; |
There was a problem hiding this comment.
Added, thanks for the suggestion!
f378e2e to
f38bcec
Compare
|
Pushed a few updates and rebased with
cc: @citizensas |
BrianHung
left a comment
There was a problem hiding this comment.
Overall, LGTM. Would update API.md and look at the possible off by one, but merge-able! Thanks 😎
| frozenLeftWidth += columns[i].width; | ||
| } | ||
| let frozenRightWidth = 0; | ||
| for (let i = columns.length - 1; i >= columns.length - 1 - freezeRightColumns; i--) { |
There was a problem hiding this comment.
Should this be i >= columns.length - freezeRightColumns? Possible off-by-one error.
There was a problem hiding this comment.
Yep, changed, thanks for the catch!
| const freezeLeftColumns = typeof freezeColumns === "number" ? freezeColumns : freezeColumns[0]; | ||
| const freezeRightColumns = typeof freezeColumns === "number" ? 0 : freezeColumns[1]; |
There was a problem hiding this comment.
Might be worth extracting into helper util if we use it so many times.
| let current: [number, number] = [-1, -1]; | ||
| let lastGroup: string | undefined; | ||
| for (let i = freezeColumns; i < columnsIn.length; i++) { | ||
| for (let i = freezeColumnsLeft as number; i < columnsIn.length - freezeColumnsRight; i++) { |
There was a problem hiding this comment.
Would cast as number above ^
0529640 to
67a8c55
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for freezing columns on the right side of the data grid. It extends the freezeColumns API to accept either a number (for backward compatibility) or a tuple [left: number, right: number] to support both left and right column freezing.
- Introduces right-side column freezing functionality to complement existing left-side freezing
- Updates rendering logic to handle positioning, clipping, and styling for right-frozen columns
- Adds comprehensive test coverage for the new freeze behavior
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/common/utils.tsx |
Adds utility function to normalize freeze column parameter |
packages/core/src/internal/data-grid/render/ |
Updates rendering functions to handle right-frozen columns |
packages/core/src/internal/data-grid/data-grid.tsx |
Modifies main data grid component to support new freezing logic |
packages/core/src/data-editor/data-editor.tsx |
Updates data editor to handle right-frozen columns in various operations |
| Test files | Adds comprehensive test coverage for right column freezing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| let clipX = 0; // this tracks the total width of sticky cols | ||
| const drawY = totalHeaderHeight + translateY; | ||
| for (const c of effectiveCols) { | ||
| const clipXRight = freezeTrailingColumns === 0 ? 0 : effectiveCols.slice(-freezeTrailingColumns).reduce((acc, col) => acc + col.width, 0); |
There was a problem hiding this comment.
The slice(-freezeTrailingColumns).reduce() operation is called on every walkColumns invocation. Consider calculating this value once and passing it as a parameter to avoid repeated array operations.
There was a problem hiding this comment.
I removed the slice call. Since freezeRightColumns is usually a small number and doesn’t grow large, I kept the calculation here.
| let clipX = 0; | ||
| for (let index = 0; index < effectiveCols.length; index++) { | ||
|
|
||
| const effectiveColsRight = freezeTrailingColumns === 0 ? [] : effectiveCols.slice(-freezeTrailingColumns); |
There was a problem hiding this comment.
Similar to the previous issue, the slice operation for right columns is repeated. This could be optimized by calculating once and reusing.
There was a problem hiding this comment.
I removed the slice call. Since freezeRightColumns is usually a small number and doesn’t grow large, I kept the calculation here.
| } | ||
|
|
||
| width = Math.min(width, effectiveWidth); | ||
| let rightX = width + 0.5; |
There was a problem hiding this comment.
[nitpick] Mutating the width parameter could lead to confusion. Consider using a local variable with a descriptive name like 'clippedWidth' instead of overwriting the parameter.
| let rightX = width + 0.5; | |
| const clippedWidth = Math.min(width, effectiveWidth); | |
| let rightX = clippedWidth + 0.5; |
| groupHeaderHeight | ||
| ); | ||
|
|
||
| width += w; |
There was a problem hiding this comment.
[nitpick] The width parameter is being mutated within the walkGroups function, which could cause confusion since width is typically expected to be read-only. Consider using a local variable to track position changes.
| width += w; | |
| currentWidth += w; |
67a8c55 to
baa35c8
Compare
Fix test to perform click with the pointer events.
48dadb9 to
67196ea
Compare
|
Hi @BrianHung @lukasmasuch, hope you're doing well. Apologies for missing your comment about updating Let me know if there's anything else you'd like me to adjust, happy to help move this forward when you have a moment! |
This MR adds support for freezing columns on the right side.
It used draft MR #973 as a base, with major fixes and improvements:
This addresses the right-side freeze column feature requested in multiple issues: #469, #522, #919, and #957.
The API remains backward compatible, following the proposal here by @jassmith: