Skip to content

Commit bbb6809

Browse files
BrianHungCopilot
andauthored
fix onColumnProposeMove rowMarkerOffset (#962)
* fix onColumnProposeMove rowMarkerOffset * fix test * only forward boolean instead of coercing [copilot]: Comparing the result to === false forces a boolean return and inverts or masks the original callback semantics. Instead, forward the actual return value (or undefined) from onColumnProposeMove so consumers can cancel by returning false and allow by returning true or nothing. Co-authored-by: Copilot <[email protected]> * coerce boolean for types but invert --------- Co-authored-by: Copilot <[email protected]>
1 parent 461f15a commit bbb6809

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/core/src/data-editor/data-editor.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,16 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
25282528
]
25292529
);
25302530

2531+
const onColumnProposeMoveImpl = whenDefined(
2532+
onColumnProposeMove,
2533+
React.useCallback(
2534+
(startIndex: number, endIndex: number) => {
2535+
return onColumnProposeMove?.(startIndex - rowMarkerOffset, endIndex - rowMarkerOffset) !== false;
2536+
},
2537+
[onColumnProposeMove, rowMarkerOffset]
2538+
)
2539+
);
2540+
25312541
const onColumnMovedImpl = whenDefined(
25322542
onColumnMoved,
25332543
React.useCallback(
@@ -4052,7 +4062,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
40524062
columns={mangledCols}
40534063
nonGrowWidth={nonGrowWidth}
40544064
drawHeader={drawHeader}
4055-
onColumnProposeMove={onColumnProposeMove}
4065+
onColumnProposeMove={onColumnProposeMoveImpl}
40564066
drawCell={drawCell}
40574067
disabledRows={disabledRows}
40584068
freezeColumns={mangledFreezeColumns}

0 commit comments

Comments
 (0)