Skip to content

Add auto-scroll during drag selection#575

Open
ChristmasSun wants to merge 2 commits intoathasdev:masterfrom
ChristmasSun:feat/drag-selection-auto-scroll
Open

Add auto-scroll during drag selection#575
ChristmasSun wants to merge 2 commits intoathasdev:masterfrom
ChristmasSun:feat/drag-selection-auto-scroll

Conversation

@ChristmasSun
Copy link

Pull Request

When selecting text by click dragging, the editor does not auto-scroll when the cursor reaches the edge of the viewport. This affects both horizontal (long lines) and vertical (many lines) selection. This pull request adds in this auto-scroll functionality.

Description

  • Add useDragScroll hook that auto-scrolls the textarea during drag selection when the cursor is near or beyond viewport edges
  • Scroll speed scales proportionally to cursor distance from the edge
  • Uses a single requestAnimationFrame loop, refs only (no state, no re-renders), zero work when not dragging
  • Dispatches scroll events to keep overlay layers in sync
  • Skip ensureCursorVisible during active drag-scroll to prevent viewport fighting

Suggested Labels

Editor

Screenshots/Videos

changes.mp4

Checklist

@mehmetozguldev mehmetozguldev self-requested a review March 13, 2026 16:49
Copy link
Member

@mehmetozguldev mehmetozguldev left a comment

Choose a reason for hiding this comment

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

Legit perfect, thank you!

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.

2 participants