fix(web): prevent pull request metadata overlap (#8790)
This commit is contained in:
1 parent
352710d497
commit
cefec32d6f
3 files changed
+59
-29
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { SearchIcon } from "lucide-react";
|
||||
import { memo } from "react";
|
||||
|
||||
import { cn } from "~/lib/utils";
|
||||
@@ -45,7 +46,7 @@ function PullRequestRowImpl({
|
||||
aria-current={selected ? "true" : undefined}
|
||||
onClick={() => onSelect(entry)}
|
||||
className={cn(
|
||||
"grid w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
||||
"grid w-full grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
||||
// Offscreen rows are skipped for style, layout and paint: a long list costs what the
|
||||
// viewport shows, not what the pages have loaded. The intrinsic size keeps the
|
||||
// scrollbar honest while a row is skipped.
|
||||
@@ -59,9 +60,30 @@ function PullRequestRowImpl({
|
||||
mergeability={entry.mergeability}
|
||||
baseBranch={entry.baseBranch}
|
||||
/>
|
||||
<span className="min-w-0">
|
||||
<span className="block truncate text-sm font-medium text-foreground">{entry.title}</span>
|
||||
<PullRequestMetaLine className="mt-0.5 text-xs text-muted-foreground/70">
|
||||
<span className="grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-0.5">
|
||||
<span className="col-start-1 row-start-1 block truncate text-sm font-medium text-foreground">
|
||||
{entry.title}
|
||||
</span>
|
||||
<span className="col-start-2 row-start-1 justify-self-end whitespace-nowrap text-xs text-muted-foreground/70 tabular-nums">
|
||||
{formatRelativeTimeLabel(entry.updatedAt)}
|
||||
</span>
|
||||
<PullRequestMetaLine className="@container/pr-row-meta col-start-1 row-start-2 overflow-hidden text-xs text-muted-foreground/70">
|
||||
{matchedElsewhere ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span className="flex min-w-6 items-center gap-1 overflow-hidden rounded-full border border-border/60 px-1 text-[10px]" />
|
||||
}
|
||||
>
|
||||
<span className="sr-only">matched in the description</span>
|
||||
<SearchIcon aria-hidden className="size-3 shrink-0" />
|
||||
<span aria-hidden className="hidden truncate @xs/pr-row-meta:block">
|
||||
matched in the description
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">Matched in the description</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
<span className="flex shrink-0 items-center gap-1">
|
||||
{showProvider ? (
|
||||
<Tooltip>
|
||||
@@ -89,15 +111,19 @@ function PullRequestRowImpl({
|
||||
</span>
|
||||
{showProjectTitle ? <span className="truncate">{entry.repository}</span> : null}
|
||||
{environmentLabel ? (
|
||||
<span className="max-w-32 shrink-0 truncate">{environmentLabel}</span>
|
||||
<span className="min-w-0 max-w-32 truncate">{environmentLabel}</span>
|
||||
) : null}
|
||||
<PullRequestActorLabel actor={entry.author} className="max-w-40 shrink-0" />
|
||||
<PullRequestActorLabel
|
||||
actor={entry.author}
|
||||
className="min-w-4 max-w-40"
|
||||
labelClassName="sr-only @xs/pr-row-meta:not-sr-only @xs/pr-row-meta:truncate"
|
||||
/>
|
||||
{/* Only a verdict somebody has actually given: "review required" is the absence of
|
||||
one, and saying so on every unreviewed row would say nothing. */}
|
||||
{entry.reviewDecision === "approved" || entry.reviewDecision === "changes-requested" ? (
|
||||
<span
|
||||
className={cn(
|
||||
"shrink-0",
|
||||
"min-w-0 truncate",
|
||||
entry.reviewDecision === "approved"
|
||||
? "text-emerald-600/90 dark:text-emerald-400/80"
|
||||
: "text-amber-600/90 dark:text-amber-400/80",
|
||||
@@ -117,16 +143,12 @@ function PullRequestRowImpl({
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{matchedElsewhere ? (
|
||||
<span className="shrink-0 rounded-full border border-border/60 px-1.5 text-[10px]">
|
||||
matched in the description
|
||||
</span>
|
||||
) : null}
|
||||
</PullRequestMetaLine>
|
||||
</span>
|
||||
<span className="flex shrink-0 flex-col items-end gap-0.5 text-xs text-muted-foreground/70 tabular-nums">
|
||||
<span>{formatRelativeTimeLabel(entry.updatedAt)}</span>
|
||||
<PullRequestDiffStat additions={entry.additions} deletions={entry.deletions} />
|
||||
<PullRequestDiffStat
|
||||
additions={entry.additions}
|
||||
deletions={entry.deletions}
|
||||
className="col-start-2 row-start-2 justify-self-end text-xs"
|
||||
/>
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
|
||||
@@ -339,17 +339,19 @@ export function PullRequestActorAvatar({
|
||||
export function PullRequestActorLabel({
|
||||
actor,
|
||||
className,
|
||||
labelClassName,
|
||||
tooltip = true,
|
||||
}: {
|
||||
actor: PullRequestActor | null;
|
||||
className?: string;
|
||||
labelClassName?: string;
|
||||
tooltip?: boolean;
|
||||
}) {
|
||||
const login = actor?.login ?? "ghost";
|
||||
const label = (
|
||||
<>
|
||||
<PullRequestActorAvatar actor={actor} />
|
||||
<span className="truncate">{login}</span>
|
||||
<span className={cn("truncate", labelClassName)}>{login}</span>
|
||||
</>
|
||||
);
|
||||
if (!tooltip) {
|
||||
|
||||
@@ -1628,11 +1628,13 @@ function CompactFilterMenu<Value extends string>({
|
||||
value,
|
||||
options,
|
||||
onChange,
|
||||
className,
|
||||
}: {
|
||||
label: string;
|
||||
value: Value;
|
||||
options: ReadonlyArray<PullRequestFilterOption<Value>>;
|
||||
onChange: (value: Value) => void;
|
||||
className?: string;
|
||||
}) {
|
||||
const current = options.find((option) => option.value === value) ?? options[0];
|
||||
if (!current) return null;
|
||||
@@ -1640,10 +1642,13 @@ function CompactFilterMenu<Value extends string>({
|
||||
<Menu>
|
||||
<MenuTrigger
|
||||
aria-label={label}
|
||||
className="inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-1.5 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground"
|
||||
className={cn(
|
||||
"inline-flex h-7 min-w-0 items-center gap-1 rounded-md px-1.5 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{current.label}
|
||||
<ChevronDownIcon aria-hidden className="size-3 text-muted-foreground/70" />
|
||||
<span className="truncate">{current.label}</span>
|
||||
<ChevronDownIcon aria-hidden className="size-3 shrink-0 text-muted-foreground/70" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="start" side="bottom" className="min-w-40">
|
||||
<MenuRadioGroup value={value} onValueChange={(next) => onChange(next as Value)}>
|
||||
@@ -1721,7 +1726,7 @@ function ExpandableSearch({
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="w-56 shrink-0"
|
||||
className="w-56 min-w-24 shrink"
|
||||
onFocus={() => onFocusWithin?.(true)}
|
||||
onBlur={() => {
|
||||
onFocusWithin?.(false);
|
||||
@@ -1808,6 +1813,7 @@ function PullRequestsColumn({
|
||||
const inFlowSearchRef = useRef<HTMLDivElement | null>(null);
|
||||
const [searchOpen, setSearchOpen] = useState(false);
|
||||
const [searchFocusToken, setSearchFocusToken] = useState(0);
|
||||
const searchExpanded = searchOpen || searchValue.length > 0;
|
||||
// Mod+F belongs to this page's own search: the desktop shell binds no find-in-page, so the
|
||||
// shortcut would otherwise do nothing. Condensed, it unfolds the topbar search; at the top,
|
||||
// it focuses the in-flow bar and selects the query the way a find field would.
|
||||
@@ -1860,20 +1866,20 @@ function PullRequestsColumn({
|
||||
>
|
||||
{titlebarControls}
|
||||
{condensed ? (
|
||||
<WorkspaceBreadcrumb ariaLabel="Pull request scope">
|
||||
{/* The page name remains the foreground anchor in both states; the live filters are
|
||||
its compact scope, grouped as the second crumb rather than pretending each menu
|
||||
is a separate page in the hierarchy. */}
|
||||
<WorkspaceBreadcrumbItem current>
|
||||
<WorkspaceBreadcrumb ariaLabel="Pull request scope" className="overflow-hidden">
|
||||
{/* An expanded search owns the scarce horizontal space. The page title stays
|
||||
available to readers while the live filters remain available in both states. */}
|
||||
<WorkspaceBreadcrumbItem current className={cn(searchExpanded && "sr-only")}>
|
||||
<h1 className="truncate">Pull Requests</h1>
|
||||
</WorkspaceBreadcrumbItem>
|
||||
<WorkspaceBreadcrumbSeparator />
|
||||
<WorkspaceBreadcrumbItem className="gap-1.5 overflow-hidden">
|
||||
{searchExpanded ? null : <WorkspaceBreadcrumbSeparator />}
|
||||
<WorkspaceBreadcrumbItem className="shrink gap-1.5">
|
||||
<CompactFilterMenu
|
||||
label="Filter by state"
|
||||
value={state}
|
||||
options={STATE_TABS}
|
||||
onChange={onState}
|
||||
className="shrink-0"
|
||||
/>
|
||||
<CompactFilterMenu
|
||||
label="Filter by involvement"
|
||||
@@ -1900,7 +1906,7 @@ function PullRequestsColumn({
|
||||
)}
|
||||
<div className="min-w-0 flex-1" />
|
||||
{condensed ? (
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
<div className="flex shrink items-center gap-1.5">
|
||||
<ExpandableSearch
|
||||
searchInput={searchInput}
|
||||
searchValue={searchValue}
|
||||
|
||||
Reference in new issue
Block a user