Skip to content

SD-2676 - fix: table selection not providing a feedback#3508

Open
chittolinag wants to merge 2 commits into
mainfrom
gabriel/sd-2676-bug-table-selection-does-not-highlight-while-dragging
Open

SD-2676 - fix: table selection not providing a feedback#3508
chittolinag wants to merge 2 commits into
mainfrom
gabriel/sd-2676-bug-table-selection-does-not-highlight-while-dragging

Conversation

@chittolinag
Copy link
Copy Markdown
Contributor

Issue

regression in v1.17.0: when the user clicks above a table and drags downward into it, the selection highlight freezes the moment the pointer crosses into the table and only resumes after it exits again.

Root cause seems to be: PR #2205 (SD-2024) added #clampHeadAtIsolatingBoundary in EditorInputManager.#handleDragSelectionAt. When the drag anchor is outside a table, the clamp pins head to the position immediately before the table for every pointermove inside it. TextSelection.create(anchor, head) therefore re-dispatches the same selection on every frame → no visual update.

Proposed solution

Remove the clamp from the drag path and let prosemirror-tables' normalizeSelection handle cross-cell drags as it did pre-1.17.0. If the original SD-2024 anchor-jump symptom re-surfaces in QA, the correct follow-up is to convert the drag to a CellSelection when head enters a table (first cell → cell-at-pointer), not to re-add the clamp.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 26, 2026

SD-2676

@chittolinag chittolinag marked this pull request as ready for review May 26, 2026 14:26
@chittolinag chittolinag requested a review from a team as a code owner May 26, 2026 14:26
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

No issues found across 2 files

Linked issue analysis

Linked issue: SD-2676: Bug: Table selection does not highlight while dragging downward inside the table

Status Acceptance criteria Notes
Dragging downward inside a table shows visible selection feedback continuously while the pointer remains inside the table PR removes the clamp that pinned the head outside the table (allowing head to resolve to hit.pos), which is the root cause described in the issue. This change directly addresses the frozen highlight while dragging inside the table.
Users do not need to move the drag outside the table boundary to see the highlight update By letting head resolve to the pointer position instead of clamping it before the table, the selection will update while the pointer remains inside the table rather than waiting for it to exit.
⚠️ Table selection behavior is visually consistent with comparable non-table text selection flows The code change restores the prior flow (defers to prosemirror-tables' normalizeSelection) which should align table selection with non-table behavior, but there are no explicit tests or screenshots in the PR validating visual parity.
⚠️ The interaction remains stable across multi-row tables and longer downward selections The fix is general (removing the clamp) and likely covers multi-row/long selections, but the PR does not add or retain tests exercising multi-row or long downward drags; test coverage was reduced (selection-isolating-boundary.test.js removed), so stability across complex tables is not explicitly validated here.

Re-trigger cubic

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f120cbfdda

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (!this.#cellAnchor) {
head = this.#clampHeadAtIsolatingBoundary(doc, anchor, head);
}
const head = hit.pos;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve drag anchor when crossing into a table

Using hit.pos directly for text-drag updates reopens the cross-boundary path that SD-2024 was guarding: when a drag starts in paragraph text and the pointer enters a table, TextSelection.create(anchorOutsideTable, headInsideTable) is handed to table-editing normalization, which can coerce the selection into a cell-based selection and move the effective anchor away from the original paragraph start. In practice this causes the selection to jump behaviorally as soon as the pointer enters the table, so the drag no longer preserves the user’s original anchor. The drag path needs an explicit outside→inside table transition strategy (e.g., controlled conversion to CellSelection) rather than passing raw inside-table heads through text selection.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@chittolinag chittolinag May 26, 2026

Choose a reason for hiding this comment

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

That's not what SD-2024 tried to fix. SD-2024's fixes when drag-selecting across inline mark boundaries (e.g. bold → italic, colored → uncolored text), but this caused the issue noticed by the user: table not being partially selected, ie, it would be selected only entirely when the cursor is placed after it.

After the fix from this PR, I tested manually the behavior that SD-2024 fixed, and it's still working, meaning that this part is not necessary.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chittolinag chittolinag changed the title fix: table selection not providing a feedback SD-2676 - fix: table selection not providing a feedback May 26, 2026
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.

5 participants