dbeaver/pro#8684 [CB] feat: add autoscroll when dragging selection#4359
Conversation
…o-scroll controller
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 36 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
This PR adds auto-scrolling support while dragging a selection in the new data spreadsheet grid, and consolidates clamp into the shared @dbeaver/js-helpers package for reuse across packages.
Changes:
- Added a
useGridAutoScrollhook (RAF-driven) plus helper utilities (getEdgeSpeed,getCellLookupPoint) and tests to support selection auto-scroll near grid edges. - Updated grid dragging logic to integrate auto-scroll and keep selection updates flowing while scrolling.
- Replaced local
clampusage in conditional formatting with@dbeaver/js-helpersand exposedclampfrom that shared package.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| webapp/yarn.lock | Adds workspace dependency entry for @dbeaver/js-helpers. |
| webapp/packages/plugin-data-viewer-conditional-formatting/tsconfig.json | Adds TS project reference to @dbeaver/js-helpers. |
| webapp/packages/plugin-data-viewer-conditional-formatting/src/utils/normalize.ts | Switches clamp import to shared helpers package. |
| webapp/packages/plugin-data-viewer-conditional-formatting/src/utils/getColorMix.ts | Switches clamp import to shared helpers package. |
| webapp/packages/plugin-data-viewer-conditional-formatting/src/GridConditionalFormattingAction.ts | Switches clamp import to shared helpers package. |
| webapp/packages/plugin-data-viewer-conditional-formatting/package.json | Declares dependency on @dbeaver/js-helpers. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useGridDragging.ts | Integrates auto-scroll into drag selection handling. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/useGridAutoScroll.ts | New hook implementing edge-based auto-scrolling loop. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/helpers/getEdgeSpeed.ts | New helper to compute scroll speed near edges. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/helpers/getEdgeSpeed.test.ts | Unit tests for edge speed computation. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/helpers/getCellLookupPoint.ts | New helper to clamp lookup point for elementFromPoint. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/helpers/getCellLookupPoint.test.ts | Unit tests for lookup point clamping. |
| webapp/common-typescript/@dbeaver/js-helpers/src/index.ts | Re-exports clamp from js-helpers. |
| webapp/common-typescript/@dbeaver/js-helpers/src/clamp.ts | Renames parameters (no functional change) and updates copyright year. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (position: IDraggingPosition, event: DraggingMouseEvent): void => { | ||
| const { startDraggingCell, currentDraggingCell } = state.current; | ||
|
|
||
| if (!startDraggingCell || (position.rowIdx === currentDraggingCell?.rowIdx && position.colIdx === currentDraggingCell.colIdx)) { |
| setOnScroll: (onScroll: (cellLookupPoint: IMousePosition) => void) => void; | ||
| } | ||
|
|
||
| function createGridAutoScrollController(): IGridAutoScrollController { |
There was a problem hiding this comment.
It seems react data grid already has this functionality built in, did you check their api? It should be possible to use their logic instead of reimplementing it ourselves.
https://comcast.github.io/react-data-grid/#/AllFeatures
| return { update, stop, setOnScroll }; | ||
| } | ||
|
|
||
| export function useGridAutoScroll(onScroll: (cellLookupPoint: IMousePosition) => void): IGridAutoScroll { |
There was a problem hiding this comment.
I think we should do the following. On cell select, run scrollToCell or scrollToRow from react data grid api, thats should be enough
Screen.Recording.2026-05-22.at.16.34.32.mov