Skip to content

Commit 73fe5c1

Browse files
MartinAyvazyanMartin Ayvazyan
authored andcommitted
fix: enable autoscroll during row reordering (glideapps#1144)
Co-authored-by: Martin Ayvazyan <ayvazyan@adobe.com> (cherry picked from commit ab70423)
1 parent 2fa1d08 commit 73fe5c1

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
@@ -4325,6 +4325,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
43254325
gridRef={gridRef}
43264326
getCellRenderer={getCellRenderer}
43274327
resizeIndicator={resizeIndicator}
4328+
setScrollDir={setScrollDir}
43284329
/>
43294330
{renameGroupNode}
43304331
{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
@@ -330,6 +330,7 @@ const GridScroller: React.FunctionComponent<ScrollingDataGridProps> = p => {
330330
smoothScrollX={p.smoothScrollX}
331331
smoothScrollY={p.smoothScrollY}
332332
resizeIndicator={p.resizeIndicator}
333+
setScrollDir={p.setScrollDir}
333334
/>
334335
</InfiniteScroller>
335336
);

0 commit comments

Comments
 (0)