SD-2676 - fix: table selection not providing a feedback#3508
SD-2676 - fix: table selection not providing a feedback#3508chittolinag wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
#clampHeadAtIsolatingBoundaryinEditorInputManager.#handleDragSelectionAt. When the drag anchor is outside a table, the clamp pinsheadto 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'normalizeSelectionhandle 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 aCellSelectionwhenheadenters a table (first cell → cell-at-pointer), not to re-add the clamp.