feat(data-grid): auto-scroll grid during drag selection#1115
Open
feat(data-grid): auto-scroll grid during drag selection#1115
Conversation
When drag-selecting cells and moving the mouse beyond the grid's visible edges, the grid now auto-scrolls in that direction and extends the selection to include newly visible cells. Scroll speed scales with distance from the edge for fine-grained control. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Guard against missing container ref in tick() by stopping auto-scroll immediately when container or table refs are unavailable. This prevents infinite recursion in test environments where RAF executes synchronously. Also prevent startAutoScroll from starting when container doesn't exist. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds auto-scroll functionality to the data grid during drag selection. When users drag-select cells and move the mouse beyond the grid's visible edges, the grid now automatically scrolls in that direction while extending the selection to include newly visible cells. The scroll speed scales with the distance from the edge, providing fine-grained control.
Changes:
- Added four new constants to configure auto-scroll behavior (edge zone, minimum/maximum speed, and selection throttle)
- Created a
dragDepsRefusinguseAsRefto maintain stable references to selection functions and grid properties - Implemented a comprehensive auto-scroll effect using
requestAnimationFramethat tracks mouse position, calculates scroll deltas, updates scroll position, and extends cell selection
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Cursor <cursoragent@cursor.com>
- Swap pinned column widths for viewport scroll area calculation in RTL - Map visual zones to correct logical column arrays (left visual = right logical in RTL) - Handle negative scrollLeft in RTL browsers correctly Co-authored-by: Cursor <cursoragent@cursor.com>
Replace complex width-based column calculations with document.elementFromPoint to directly find the cell under the mouse cursor. This works correctly in both LTR and RTL without manual coordinate translation or zone mapping. Co-authored-by: Cursor <cursoragent@cursor.com>
In RTL, logical column 0 is on the visual right. The previous code measured absX from the visual left, mapping to the wrong column. Now measures from the visual right in RTL mode, correctly matching logical column order. Also handles Firefox RTL scrollLeft (non-negative) vs Chrome (negative) for the scroll offset calculation. Co-authored-by: Cursor <cursoragent@cursor.com>
When only scrolling vertically (no horizontal auto-scroll), keep the current selection column instead of recalculating it from pixel math. The scrollLeft-based column resolution is unreliable in RTL because scrollLeft=0 is ambiguous between Chrome's initial state and Firefox's fully-scrolled state. Column changes during horizontal auto-scroll still use the full calculation; vertical-only scrolling preserves the column from onCellMouseEnter. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # public/r/data-grid.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When drag-selecting cells and moving the mouse beyond the grid's visible edges, the grid now auto-scrolls in that direction and extends the selection to include newly visible cells. Scroll speed scales with distance from the edge for fine-grained control.