Skip to content

Commit d7ab057

Browse files
author
Martin Ayvazyan
committed
fix: enable autoscroll during row reordering
1 parent f1a7c9b commit d7ab057

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4311,6 +4311,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
43114311
gridRef={gridRef}
43124312
getCellRenderer={getCellRenderer}
43134313
resizeIndicator={resizeIndicator}
4314+
setScrollDir={setScrollDir}
43144315
/>
43154316
{renameGroupNode}
43164317
{overlay !== undefined && (

packages/core/src/internal/data-grid-dnd/data-grid-dnd.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export interface DataGridDndProps extends Props {
7676
readonly maxColumnWidth: number;
7777
readonly minColumnWidth: number;
7878
readonly lockColumns: number;
79+
readonly setScrollDir: (dir: GridMouseEventArgs["scrollEdge"] | undefined) => void;
7980
}
8081

8182
// Dear Past Jason,
@@ -118,6 +119,7 @@ const DataGridDnd: React.FunctionComponent<DataGridDndProps> = p => {
118119
onItemHovered,
119120
onDragStart,
120121
canvasRef,
122+
setScrollDir
121123
} = p;
122124

123125
const canResize = (onColumnResize ?? onColumnResizeEnd ?? onColumnResizeStart) !== undefined;
@@ -134,12 +136,13 @@ const DataGridDnd: React.FunctionComponent<DataGridDndProps> = p => {
134136
} else if (dragRow !== undefined && row !== undefined) {
135137
setDragRowActive(true);
136138
setDropRow(Math.max(0, row));
139+
setScrollDir(args.scrollEdge);
137140
// Don't emit onItemHovered if resizing or reordering a column or row.
138141
} else if (resizeCol === undefined && !dragColActive && !dragRowActive) {
139142
onItemHovered?.(args);
140143
}
141144
},
142-
[dragCol, dragRow, dropCol, onItemHovered, lockColumns, resizeCol, dragColActive, dragRowActive]
145+
[dragCol, dragRow, dropCol, onItemHovered, lockColumns, resizeCol, dragColActive, dragRowActive, setScrollDir]
143146
);
144147

145148
const canDragCol = onColumnMoved !== undefined;

packages/core/src/internal/data-grid-search/data-grid-search.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ const DataGridSearch: React.FunctionComponent<DataGridSearchProps> = p => {
567567
smoothScrollX={p.smoothScrollX}
568568
smoothScrollY={p.smoothScrollY}
569569
resizeIndicator={p.resizeIndicator}
570+
setScrollDir={p.setScrollDir}
570571
/>
571572
{searchbox}
572573
</>

packages/core/src/internal/scrolling-data-grid/scrolling-data-grid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ const GridScroller: React.FunctionComponent<ScrollingDataGridProps> = p => {
339339
smoothScrollX={p.smoothScrollX}
340340
smoothScrollY={p.smoothScrollY}
341341
resizeIndicator={p.resizeIndicator}
342+
setScrollDir={p.setScrollDir}
342343
/>
343344
</InfiniteScroller>
344345
);

0 commit comments

Comments
 (0)