Skip to content

fix(editor): require pointer movement before extending drag selection#3012

Open
luccas-harbour wants to merge 2 commits intomainfrom
luccas/sd-2356-bug-clicking-into-table-selects-text
Open

fix(editor): require pointer movement before extending drag selection#3012
luccas-harbour wants to merge 2 commits intomainfrom
luccas/sd-2356-bug-clicking-into-table-selects-text

Conversation

@luccas-harbour
Copy link
Copy Markdown
Contributor

Summary

  • Fix SD-2356: clicking into a table (or anywhere in the document) could select text because tiny pointer jitter on mousedown immediately engaged drag selection.
  • Gate drag selection and edge auto-scroll behind a 5px Euclidean movement threshold from the drag start point, matching the distance gating already used for multi-click detection.
  • Once the threshold is exceeded for a given drag, it stays exceeded until the drag ends (so you can't drop back below the threshold mid-drag).

Changes

  • packages/super-editor/src/editors/v1/core/presentation-editor/pointer-events/EditorInputManager.ts
    • New DRAG_SELECTION_DISTANCE_THRESHOLD_PX = 5 constant.
    • Track #dragStartClient and #dragThresholdExceeded state; reset wherever drag state is cleared (drag start, end, cancel, teardown).
    • New #hasExceededDragSelectionThreshold() helper; pointer-move handler returns early before extending selection or updating auto-scroll until the threshold is crossed.
  • packages/super-editor/src/editors/v1/core/presentation-editor/tests/EditorInputManager.dragAutoScroll.test.ts
    • Movement of (3, 3) stays below threshold → no dispatch / scheduleSelectionUpdate.
    • Movement of (3, 4) reaches the Euclidean threshold → exactly one selection extension.
    • Edge auto-scroll does not start while pointer movement stays below the threshold near the edge.

Clicking into a table (or anywhere in the document) could select text
because tiny pointer jitter on mousedown immediately triggered drag
selection. Add a 5px Euclidean distance threshold before drag selection
and edge auto-scroll engage, matching the multi-click distance gating
already used for click detection.
@luccas-harbour luccas-harbour requested a review from a team as a code owner April 29, 2026 20:03
@linear
Copy link
Copy Markdown

linear Bot commented Apr 29, 2026

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants