fix(web): stop long GitLab row titles drawing over the row actions (#2057)

This commit is contained in:
nova28
2026-07-30 21:48:03 +08:00
committed by GitHub
parent 789b658a1c
commit 21742aa3ef
4 changed files with 62 additions and 27 deletions
@@ -1,7 +1,6 @@
"use client";
import Link from "@/components/routing/app-link";
import { IconCircle, IconCircleCheck, IconExternalLink } from "@tabler/icons-react";
import { IconCircle, IconCircleCheck } from "@tabler/icons-react";
import { Badge } from "@kandev/ui/badge";
import { Spinner } from "@kandev/ui/spinner";
import { cn, formatRelativeTime } from "@/lib/utils";
@@ -9,6 +8,7 @@ import type { Issue } from "@/lib/types/gitlab";
import type { GitLabLaunchPayload, GitLabTaskPreset } from "./quick-task-launcher";
import { StartTaskMenu } from "./start-task-menu";
import { SubscriptionToggle } from "../subscription-toggle";
import { RowTitleLink } from "./row-title-link";
type IssueListProps = {
items: Issue[];
@@ -62,15 +62,7 @@ function IssueRow({
>
<StateIcon className={cn("h-4 w-4 mt-1 shrink-0", stateClass)} />
<div className="min-w-0 flex-1">
<Link
href={issue.web_url}
target="_blank"
rel="noopener noreferrer"
className="text-sm font-semibold hover:underline inline-flex items-center gap-1.5 truncate cursor-pointer"
>
<span className="truncate">{issue.title}</span>
<IconExternalLink className="h-3 w-3 shrink-0 text-muted-foreground" />
</Link>
<RowTitleLink href={issue.web_url} title={issue.title} />
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 mt-0.5 text-xs text-muted-foreground">
<span className="whitespace-nowrap">
{issue.project_path}#{issue.iid}
@@ -1,12 +1,6 @@
"use client";
import Link from "@/components/routing/app-link";
import {
IconGitPullRequest,
IconGitPullRequestClosed,
IconGitMerge,
IconExternalLink,
} from "@tabler/icons-react";
import { IconGitPullRequest, IconGitPullRequestClosed, IconGitMerge } from "@tabler/icons-react";
import type { Icon } from "@tabler/icons-react";
import { Spinner } from "@kandev/ui/spinner";
import { cn, formatRelativeTime } from "@/lib/utils";
@@ -15,6 +9,7 @@ import type { GitLabLaunchPayload, GitLabTaskPreset } from "./quick-task-launche
import { gitLabMRKey } from "@/lib/gitlab-identity";
import { MRRowTaskIndicator } from "./mr-row-task-indicator";
import { StartTaskMenu } from "./start-task-menu";
import { RowTitleLink } from "./row-title-link";
type MRListProps = {
items: MR[];
@@ -55,15 +50,7 @@ function MRRow({
>
<StateIcon className={cn("h-4 w-4 mt-1 shrink-0", stateIconClass)} />
<div className="min-w-0 flex-1">
<Link
href={mr.web_url}
target="_blank"
rel="noopener noreferrer"
className="text-sm font-semibold hover:underline inline-flex items-center gap-1.5 truncate cursor-pointer"
>
<span className="truncate">{mr.title}</span>
<IconExternalLink className="h-3 w-3 shrink-0 text-muted-foreground" />
</Link>
<RowTitleLink href={mr.web_url} title={mr.title} />
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 mt-0.5 text-xs text-muted-foreground">
<span className="whitespace-nowrap">
{mr.project_path}!{mr.iid}
@@ -0,0 +1,29 @@
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it } from "vitest";
import { RowTitleLink } from "./row-title-link";
const longTitle =
"§7 item 4 (km-product#27) — EntityLocker is not the REQ-011 FR-8 answer lock (no change proposed; recording the distinction)";
afterEach(cleanup);
describe("RowTitleLink", () => {
it("keeps a long title inside its column instead of overlapping row actions", () => {
render(<RowTitleLink href="https://gitlab.example.com/x/-/issues/3" title={longTitle} />);
const link = screen.getByRole("link");
// Block-level flex: an inline-flex link sizes to content and overflows the row.
expect(link.className).toContain("flex");
expect(link.className).not.toContain("inline-flex");
expect(link.className).toContain("min-w-0");
const text = screen.getByText(longTitle);
expect(text.className).toContain("truncate");
});
it("exposes the full title on hover since the text may be clipped", () => {
render(<RowTitleLink href="https://gitlab.example.com/x/-/issues/3" title={longTitle} />);
expect(screen.getByRole("link").getAttribute("title")).toBe(longTitle);
});
});
@@ -0,0 +1,27 @@
"use client";
import Link from "@/components/routing/app-link";
import { IconExternalLink } from "@tabler/icons-react";
/**
* Title link for GitLab issue/MR rows.
*
* Must stay block-level (`flex`, not `inline-flex`): an inline-flex link sizes
* itself to its content, so a long title escapes the row's `min-w-0 flex-1`
* column and draws over the row actions. Truncation belongs on the text span —
* `overflow-hidden` zeroes its automatic minimum size so it can shrink.
*/
export function RowTitleLink({ href, title }: { href: string; title: string }) {
return (
<Link
href={href}
target="_blank"
rel="noopener noreferrer"
title={title}
className="flex min-w-0 items-center gap-1.5 text-sm font-semibold hover:underline cursor-pointer"
>
<span className="truncate">{title}</span>
<IconExternalLink className="h-3 w-3 shrink-0 text-muted-foreground" />
</Link>
);
}