From 917796da57ccb8108e16d60ca249acb133947bd2 Mon Sep 17 00:00:00 2001 From: Naiyuan Qing <145280634+NevilleQingNY@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:37:08 +0800 Subject: [PATCH] fix(issues): keep sticky comment highlight consistent --- .../views/issues/components/comment-card.tsx | 65 ++++++++++++++----- .../issues/components/issue-detail.test.tsx | 4 +- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsx index 5c68507e7..e4e33ecc7 100644 --- a/packages/views/issues/components/comment-card.tsx +++ b/packages/views/issues/components/comment-card.tsx @@ -1,6 +1,6 @@ "use client"; -import { memo, useCallback, useRef, useState } from "react"; +import { memo, useCallback, useRef, useState, type ReactNode } from "react"; import { CheckCircle2, ChevronRight, ListChevronsDownUp, Copy, MoreHorizontal, Pencil, RotateCcw, Trash2 } from "lucide-react"; import { toast } from "sonner"; import { Card } from "@multica/ui/components/ui/card"; @@ -43,6 +43,41 @@ import { useT } from "../../i18n"; import { CommentsFoldBar } from "./resolved-thread-bar"; import { deriveThreadResolution } from "./thread-utils"; +const highlightedCommentBackgroundClass = + "bg-[color-mix(in_srgb,var(--card)_95%,var(--brand)_5%)]"; +const highlightedCommentFadeClass = + "after:from-[color-mix(in_srgb,var(--card)_95%,var(--brand)_5%)]"; + +function StickyHeaderShell({ + className, + sticky = true, + highlighted, + children, +}: { + className?: string; + sticky?: boolean; + highlighted?: boolean; + children: ReactNode; +}) { + if (!sticky) { + return
{children}
; + } + + return ( +
+
+ {children} +
+
+ ); +} + // --------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------- @@ -377,11 +412,9 @@ function CommentRow({ row box, so a LONG reply keeps its author + actions visible while you scroll its body, then releases once this reply ends. bg-card occludes the body scrolling underneath. */} -
@@ -474,7 +507,7 @@ function CommentRow({ onConfirm={() => onDelete(entry.id)} />
- + {edit.editing ? (
+ {onCollapseResolved && (
+ {/* Collapsible body */} @@ -846,7 +877,7 @@ function CommentCardImpl({ )} {resolutionReply && ( -
+
( -
+
{ // After expansion, the reply must appear in the DOM (inside the now // -unfolded CommentCard) and the deep-link effect must land on + highlight - // it. The reply highlight renders as a bg tint on its row (see + // it. The reply highlight renders as a computed bg tint on its row (see // CommentCard's reply branch), so assert the row carries the brand tint. await waitFor(() => { expect( @@ -1078,7 +1078,7 @@ describe("IssueDetail (shared)", () => { await waitFor(() => { expect( document.getElementById("comment-reply-1")?.className, - ).toMatch(/bg-brand/); + ).toContain("bg-[color-mix(in_srgb,var(--card)_95%,var(--brand)_5%)]"); }); }); });