From de107e145c58f9f0b357022ade4ab0fb4b91c85c Mon Sep 17 00:00:00 2001 From: LU XIANGRUI <1078666705@qq.com> Date: Mon, 16 Nov 2026 15:25:44 +0900 Subject: [PATCH] fix(vcs): keep the Git log commit card open while scrolling inside it (#3691) A commit row closed its card on any capture-phase scroll so that scrolling the log, which moves the anchor, hides it; scrolling a long message inside the card fired the same listener. Scrolls inside the card no longer close it; the log and elsewhere still do. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com> --- e2e/gitLogScrollbar.spec.ts | 23 ++++++++++++++++++++++- src/features/vcs/GitLog.tsx | 10 ++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/e2e/gitLogScrollbar.spec.ts b/e2e/gitLogScrollbar.spec.ts index f2536143d..fa7daeb35 100644 --- a/e2e/gitLogScrollbar.spec.ts +++ b/e2e/gitLogScrollbar.spec.ts @@ -40,7 +40,11 @@ test.beforeEach(async ({ workbench: page }) => { h.vcs_commit_files = () => []; h.vcs_log_details_batch = ({ revisions }) => (revisions as string[]).map((revision) => ({ - message: `Commit ${parseInt(revision, 16)}`, + // Commit 2 carries a message longer than its tooltip. + message: + parseInt(revision, 16) === 2 + ? `Commit 2\n\n${Array.from({ length: 80 }, (_, i) => `Line ${i + 1}`).join("\n")}` + : `Commit ${parseInt(revision, 16)}`, containingBranches: [], signature: "N", signer: "", @@ -192,3 +196,20 @@ test("keeps recycled commit tooltips closed until the pointer moves after fast s await list.getByText(`Commit ${index}`, { exact: true }).hover(); await expect(page.getByRole("tooltip")).toContainText(`Commit ${index}`); }); + +test("keeps a commit tooltip open while its long message scrolls, and closes it when the log scrolls", async ({ + workbench: page, +}) => { + const list = page.getByRole("listbox", { name: "Commits" }); + await list.getByText("Commit 2", { exact: true }).hover(); + const tooltip = page.getByRole("tooltip"); + await expect(tooltip).toContainText("Line 80"); + const box = (await tooltip.boundingBox())!; + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 5 }); + await page.mouse.wheel(0, 400); + await expect.poll(() => tooltip.evaluate((element) => element.scrollTop)).toBeGreaterThan(0); + await page.waitForTimeout(300); + await expect(tooltip).toBeVisible(); + await list.evaluate((element) => (element.scrollTop += 260)); + await expect(tooltip).toHaveCount(0); +}); diff --git a/src/features/vcs/GitLog.tsx b/src/features/vcs/GitLog.tsx index 809233b56..c02b20f78 100644 --- a/src/features/vcs/GitLog.tsx +++ b/src/features/vcs/GitLog.tsx @@ -2122,11 +2122,17 @@ function CommitRowView({ const merge = opts.highlightMerges && c.parents.length > 1; const subjectRef = useRef(null); const [tooltip, setTooltip] = useState(false); + const tooltipBody = useRef(null); const tooltipTimer = useRef | undefined>(undefined); useEffect(() => () => clearTimeout(tooltipTimer.current), []); useEffect(() => { if (!tooltip) return; - const hide = () => setTooltip(false); + // Scrolling the log moves the anchor away; scrolling a long message inside the card doesn't. + const hide = (e: Event) => { + const card = tooltipBody.current?.closest("[data-popup]"); + if (e.target instanceof Node && card?.contains(e.target)) return; + setTooltip(false); + }; window.addEventListener("scroll", hide, true); return () => window.removeEventListener("scroll", hide, true); }, [tooltip]); @@ -2192,7 +2198,7 @@ function CommitRowView({ onClose={() => setTooltip(false)} className={styles.commitTooltip} > -
clearTimeout(tooltipTimer.current)} onPointerLeave={leaveTooltip}> +
clearTimeout(tooltipTimer.current)} onPointerLeave={leaveTooltip}>