diff --git a/src/features/vcs/GitLog.module.css b/src/features/vcs/GitLog.module.css index d455d882a7..c543dd8f83 100644 --- a/src/features/vcs/GitLog.module.css +++ b/src/features/vcs/GitLog.module.css @@ -310,7 +310,9 @@ display: inline-flex; align-items: center; gap: 8px; - max-width: 50%; + /* May use the whole subject cell when space allows (#2447); shrinks with + per-label ellipsis before crowding out the commit message. */ + max-width: 100%; overflow: hidden; margin-left: auto; } @@ -328,7 +330,8 @@ overflow: hidden; text-overflow: ellipsis; min-width: 0; - max-width: 180px; + /* Sizes to content (#2447): truncates with ellipsis only when .refs runs + out of room; the full name stays available via the title tooltip. */ } /* Outlined tag glyph in the ref's colour. */ .ref::before { diff --git a/src/features/vcs/__tests__/gitLogRefLabels.test.tsx b/src/features/vcs/__tests__/gitLogRefLabels.test.tsx new file mode 100644 index 0000000000..c06eef6090 --- /dev/null +++ b/src/features/vcs/__tests__/gitLogRefLabels.test.tsx @@ -0,0 +1,32 @@ +import { readFileSync } from "node:fs"; +import { render, screen } from "@testing-library/react"; +import { describe, expect, it } from "vitest"; +import { RefLabels } from "../GitLog"; + +const css = readFileSync("src/features/vcs/GitLog.module.css", "utf8"); + +const LONG_LOCAL = "feature-connection-storm-v2"; +const LONG_REMOTE = "gitlab/feature-connection-storm-v2"; +const REMOTES = new Set([LONG_REMOTE]); + +describe("RefLabels long branch names (#2447)", () => { + it("renders full names with title tooltips in regular mode", () => { + render(); + expect(screen.getByTitle(LONG_LOCAL)).toHaveTextContent(LONG_LOCAL); + expect(screen.getByTitle(LONG_REMOTE)).toHaveTextContent(LONG_REMOTE); + }); + + it("absorbs the remote into the local label in compact mode", () => { + render(); + expect(screen.getByTitle(`${LONG_LOCAL}, ${LONG_REMOTE}`)).toHaveTextContent(`gitlab & ${LONG_LOCAL}`); + }); + + it("lets labels size to content: no fixed pixel cap, ellipsis and clipping kept", () => { + const refBlocks = [...css.matchAll(/\.ref\s*\{([^}]*)\}/g)].map((m) => m[1]); + expect(refBlocks.length).toBeGreaterThan(0); + for (const block of refBlocks) expect(block).not.toMatch(/max-width:\s*\d+px/); + expect(refBlocks[0]).toMatch(/text-overflow:\s*ellipsis/); + const refsBlock = css.match(/\.refs\s*\{([^}]*)\}/)?.[1] ?? ""; + expect(refsBlock).toMatch(/overflow:\s*hidden/); + }); +});