Skip to content

dbeaver/pro#8684 [CB] feat: add autoscroll when dragging selection#4359

Open
SychevAndrey wants to merge 7 commits into
develfrom
8684-cb-cannot-scroll-while-extending-selection-to-rows-outside-the-visible-area-in-data-editor
Open

dbeaver/pro#8684 [CB] feat: add autoscroll when dragging selection#4359
SychevAndrey wants to merge 7 commits into
develfrom
8684-cb-cannot-scroll-while-extending-selection-to-rows-outside-the-visible-area-in-data-editor

Conversation

@SychevAndrey
Copy link
Copy Markdown
Contributor

Screen.Recording.2026-05-22.at.16.34.32.mov

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 22, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 36 complexity

Metric Results
Complexity 36

View in Codacy

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useGridAutoScroll hook (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 clamp usage in conditional formatting with @dbeaver/js-helpers and exposed clamp from 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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do the following. On cell select, run scrollToCell or scrollToRow from react data grid api, thats should be enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants