Skip to content

Commit c18f35f

Browse files
committed
fix(web): hide empty comment tooltips
1 parent a2a3d81 commit c18f35f

2 files changed

Lines changed: 50 additions & 20 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { renderToStaticMarkup } from "react-dom/server";
2+
import { describe, expect, it, vi } from "vite-plus/test";
3+
4+
import { ComposerPendingReviewComments } from "./ComposerPendingReviewComments";
5+
6+
describe("ComposerPendingReviewComments", () => {
7+
it("keeps an empty-note chip visible without an empty tooltip", () => {
8+
const markup = renderToStaticMarkup(
9+
<ComposerPendingReviewComments
10+
comments={[
11+
{
12+
id: "selection-1",
13+
sectionId: "pull-request:42",
14+
sectionTitle: "PR #42",
15+
filePath: "src/app.ts",
16+
startIndex: 3,
17+
endIndex: 5,
18+
rangeLabel: "L4-L6",
19+
text: "",
20+
diff: "+const answer = 42;",
21+
},
22+
]}
23+
onRemove={vi.fn()}
24+
/>,
25+
);
26+
27+
expect(markup).toContain("src/app.ts L4-L6");
28+
expect(markup).not.toContain('data-slot="tooltip-trigger"');
29+
});
30+
});

‎apps/web/src/components/chat/ComposerPendingReviewComments.tsx‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ export function ComposerPendingReviewComments({
2727
<div className={cn("flex flex-wrap gap-1.5", className)}>
2828
{comments.map((comment) => {
2929
const label = `${comment.filePath} ${comment.rangeLabel}`;
30+
const chip = (
31+
<span key={comment.id} className={cn(COMPOSER_INLINE_CHIP_CLASS_NAME, "pr-1")}>
32+
<MessageCircle className={cn(COMPOSER_INLINE_CHIP_ICON_CLASS_NAME, "size-3.5")} />
33+
<span className={COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME}>{label}</span>
34+
<button
35+
type="button"
36+
aria-label={`Remove comment on ${label}`}
37+
className={COMPOSER_INLINE_CHIP_DISMISS_BUTTON_CLASS_NAME}
38+
onClick={(event) => {
39+
event.preventDefault();
40+
event.stopPropagation();
41+
onRemove(comment.id);
42+
}}
43+
>
44+
<X className="size-3" aria-hidden />
45+
</button>
46+
</span>
47+
);
48+
if (comment.text.length === 0) return chip;
3049
return (
3150
<Tooltip key={comment.id}>
32-
<TooltipTrigger
33-
render={
34-
<span className={cn(COMPOSER_INLINE_CHIP_CLASS_NAME, "pr-1")}>
35-
<MessageCircle className={cn(COMPOSER_INLINE_CHIP_ICON_CLASS_NAME, "size-3.5")} />
36-
<span className={COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME}>{label}</span>
37-
<button
38-
type="button"
39-
aria-label={`Remove comment on ${label}`}
40-
className={COMPOSER_INLINE_CHIP_DISMISS_BUTTON_CLASS_NAME}
41-
onClick={(event) => {
42-
event.preventDefault();
43-
event.stopPropagation();
44-
onRemove(comment.id);
45-
}}
46-
>
47-
<X className="size-3" aria-hidden />
48-
</button>
49-
</span>
50-
}
51-
/>
51+
<TooltipTrigger render={chip} />
5252
<TooltipPopup side="top" className="max-w-96 whitespace-pre-wrap leading-tight">
5353
{comment.text}
5454
</TooltipPopup>

0 commit comments

Comments
 (0)