Skip to content

Keep comment thread open when drag-selecting its text#8

Merged
AnnaXWang merged 1 commit into
mainfrom
hypeship/fix-comment-thread-drag-close
Jul 9, 2026
Merged

Keep comment thread open when drag-selecting its text#8
AnnaXWang merged 1 commit into
mainfrom
hypeship/fix-comment-thread-drag-close

Conversation

@AnnaXWang

@AnnaXWang AnnaXWang commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Opening a comment thread and then click-dragging to highlight the comment text (to copy it) closes the thread on mouse release. Selecting text to copy shouldn't be a close gesture — the thread should stay open until explicitly closed.

Cause

The comment card's onClick toggles its pinned/open state for any click outside a data-no-pin region. A click-drag-release over the comment body still emits a click, so selecting text fired the toggle and closed the pinned thread. (The comment body isn't marked data-no-pin, unlike the actions row/composer/reactions.)

Fix

Distinguish a real click from a drag before toggling, in the card handler:

  • record the pointer-down position on onMouseDown;
  • on onClick, skip the toggle if the pointer moved more than ~4px (a drag), or if text ended up selected within the card.

A plain click still opens/closes the thread; a drag-to-highlight now leaves it open, so Cmd+C works. Explicit close paths (✕, clicking the highlight, switching cards) are unchanged.

Testing

  • npm test — 108 passing, no regressions.
  • tsc --noEmit clean.
  • Manual: open a thread, drag-select the body → thread stays open and text is selectable/copyable; a normal click still toggles it.

Comment-card interactions aren't unit-tested in this repo (client-only DOM behavior), so the interaction check above is manual.


Note

Low Risk
Small client-only interaction tweak in the comment card click handler; no API or auth changes.

Overview
Comment rail cards no longer treat a drag-to-select over the comment body as a pin/unpin click. The card records pointer position on mousedown and, on click, skips onPin() when the pointer moved more than ~4px—so copy-by-highlighting leaves the thread open while a normal click still toggles it.

data-no-pin regions (actions, composer, reactions) are unchanged; only the card-level click handler gains this drag guard.

Reviewed by Cursor Bugbot for commit 2535b4a. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
justhtml Ready Ready Preview, Comment Jul 8, 2026 11:34pm

@AnnaXWang AnnaXWang marked this pull request as ready for review July 8, 2026 23:14
@AnnaXWang AnnaXWang requested a review from rgarcia July 8, 2026 23:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4ea2d56. Configure here.

Comment thread app/d/[slug]/CommentsShell.tsx Outdated
Clicking a comment card toggles the thread open/closed, but a click that
ended a drag-to-highlight (selecting the comment body to copy) also fired
the toggle and closed the thread. Distinguish a real click from a drag:
skip the toggle when the pointer moved past a small threshold or text ended
up selected within the card.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@rgarcia rgarcia left a comment

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.

reviewed — clean, well-scoped fix. distinguishing a click from a drag-release via pointer movement is the right approach, comments explain the why, and no new deps. lgtm.

@AnnaXWang AnnaXWang merged commit 7ea7ba5 into main Jul 9, 2026
5 checks passed
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