Skip to content

fix: allow caret placement inside commented text on click (SD-2442)#2708

Open
luccas-harbour wants to merge 2 commits intomainfrom
luccas/sd-2442-bug-cursor-cannot-be-placed-in-text-associated-with-a
Open

fix: allow caret placement inside commented text on click (SD-2442)#2708
luccas-harbour wants to merge 2 commits intomainfrom
luccas/sd-2442-bug-cursor-cannot-be-placed-in-text-associated-with-a

Conversation

@luccas-harbour
Copy link
Copy Markdown
Contributor

Summary

  • Fixes a bug where clicking on text covered by a single comment highlight would short-circuit caret placement, making it impossible to position the cursor within commented text
  • Direct clicks on comment highlight spans now fall through to the generic pointer handling, allowing normal caret placement while still supporting nearby/gap clicks for comment activation
  • Adds a Playwright behavior test (sd-2442-commented-text-caret.spec.ts) and updates existing unit tests to reflect the new behavior

@linear
Copy link
Copy Markdown

linear bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

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

@luccas-harbour fix looks good, no bugs found. clicking on commented text places the caret correctly and the right comment gets selected — tested all the cases (single comment, overlapping comments, re-clicking same comment).

one side effect: clicking commented text highlights the comment bubble but doesn't open the reply thread like google docs does. filed SD-2460 for that — not a blocker here.

left one small inline comment on the test helpers.

throw new Error(`Could not resolve coordinates for document position ${pos}`);
}

return coords;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this math always simplifies to coords.left + 1 — the min/max wrapping doesn't do anything. same thing in rightClickAtDocPos below. worth simplifying?

Suggested change
return coords;
const x = coords.left + 1;

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.

3 participants