Repository navigation
fix(client): keep All Comments open when a click finishes a text selection - #473
Open
nikvakhrameev wants to merge 1 commit into
Open
nikvakhrameev wants to merge 1 commit into
nikvakhrameev wants to merge 1 commit into
Conversation
…ction Browsers fire `click` after any mousedown/mouseup pair inside the same element, including a mouse drag that only selects text. In the All Comments modal every thread card handles `click` by navigating to the thread and closing the modal, so selecting text inside a comment closed the modal instead of leaving the selection in place. Add a `hasActiveTextSelection()` helper to `domUtils` and bail out of the card's click handler while a non-empty selection exists. A plain click still navigates and closes the modal as before.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Selecting text inside the All Comments modal closes the modal.
Reproduction:
Browsers fire
clickafter any mousedown/mouseup pair inside the same element, including a drag that only selects text. Each thread card inCommentsListModalhandlesclickby callingonNavigate(thread)andonClose(), so a text selection is treated exactly like a click on the card.Expected: selecting text inside the modal leaves it open with the selection intact, while a plain click still navigates to the thread and closes the modal.
Implementation notes
src/client/utils/domUtils.ts: addhasActiveTextSelection(), which reports whetherdocument.getSelection()is non-collapsed and non-empty.src/client/components/CommentsListModal.tsx: in the cardonClick, return early whenhasActiveTextSelection()is true (aftere.stopPropagation(), so the click still does not fall through to the backdrop). No other behaviour changes;setSelectedIndexandhandleThreadClickrun as before for a regular click.src/client/components/CommentsListModal.test.tsx: add a regression test next tonavigates when clicking a thread. It builds a realRangeover a comment body (happy-dom implementsSelection/Range), firesclick, and assertsonNavigate/onCloseare not called; it then clears the selection, clicks again, and asserts the normal navigate-and-close path still works. The test fails onmainand passes with this change.Manual verification
pnpm check,pnpm format,pnpm knip,pnpm test(861 passed, 2 skipped),pnpm buildall pass locally; lefthook pre-commit and pre-push hooks ran and passed.pnpm dev, open All Comments, drag-select text inside a comment body and release: the modal stays open and the text stays selected.UI changes
None visible. No new elements or styling; only the click handling changes, so no screenshots or
docs/imagesupdates are needed.🤖 Generated with Claude Code