fix(web): PR code toolbar no longer overlaps in narrow panels (#15561)

This commit is contained in:
oliver authored and GitHub committed 2026-10-08 02:45:07 -03:00
1 parent e803242d93
commit ed27eb724b
1 file changed
+115 -63
@@ -19,6 +19,7 @@ import {
MessageSquareOffIcon,
PilcrowIcon,
Rows3Icon,
Settings2Icon,
TextWrapIcon,
TriangleAlertIcon,
} from "lucide-react";
@@ -69,10 +70,12 @@ import { Checkbox } from "../ui/checkbox";
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "../ui/menu";
import { toastManager } from "../ui/toast";
@@ -1075,8 +1078,13 @@ function PullRequestCodeTab({
}
}, [commit, onSelectedCommitChange, selectedCommit]);
const scopeLabel = selectedCommit ? selectedCommit.messageHeadline : "All commits";
const changeIgnoreWhitespace = (next: boolean) => {
setIgnoreWhitespace(next);
setDraft(null);
setSelectedLines(null);
};
const toolbar = (
<div className="flex h-10 min-h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 bg-background px-4 text-xs text-muted-foreground">
<div className="@container flex h-10 min-h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 bg-background px-4 text-xs text-muted-foreground">
<div className="flex min-w-0 flex-1 items-center gap-3">
{/* A host that reports no commits has nothing to scope by, and a dropdown whose only
entry is the scope already showing is a control that does nothing. */}
@@ -1133,7 +1141,7 @@ function PullRequestCodeTab({
) : null}
{/* One count, and the caveats as icons that carry their own words. Spelled out they
competed for a strip this narrow and every one of them truncated to nothing. */}
<PullRequestMetaLine className="shrink-0">
<PullRequestMetaLine>
<span className="shrink-0 tabular-nums">
{files.length} {files.length === 1 ? "file" : "files"}
{nextCursor === null ? "" : "+"}
@@ -1224,30 +1232,113 @@ function PullRequestCodeTab({
</PullRequestMetaLine>
</div>
<div className="flex shrink-0 items-center gap-1">
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={
ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"
<DropdownMenu>
<Tooltip>
<TooltipTrigger
render={
<DropdownMenuTrigger
render={<Button size="icon-sm" variant="ghost" />}
className="@lg:hidden"
aria-label="Diff options"
/>
}
>
<Settings2Icon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">Diff options</TooltipPopup>
</Tooltip>
<DropdownMenuContent align="end">
<DropdownMenuCheckboxItem
checked={ignoreWhitespace}
onCheckedChange={(checked) => changeIgnoreWhitespace(checked)}
>
Hide whitespace changes
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem
checked={wordWrap}
onCheckedChange={(checked) => setWordWrap(checked)}
>
Wrap lines
</DropdownMenuCheckboxItem>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup
value={diffLayout}
onValueChange={(value) => {
if (value === "stacked" || value === "split") {
updateClientSettings({ diffLayout: value });
}
variant="ghost"
size="sm"
pressed={ignoreWhitespace}
onPressedChange={(pressed) => {
setIgnoreWhitespace(Boolean(pressed));
setDraft(null);
setSelectedLines(null);
}}
/>
}
}}
>
<DropdownMenuRadioItem value="stacked" closeOnClick>
Stacked
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="split" closeOnClick>
Split
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
<div className="hidden items-center gap-1 @lg:flex">
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={
ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"
}
variant="ghost"
size="sm"
pressed={ignoreWhitespace}
onPressedChange={(pressed) => changeIgnoreWhitespace(Boolean(pressed))}
/>
}
>
<PilcrowIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
</TooltipPopup>
</Tooltip>
<ToggleGroup
aria-label="Diff layout"
className="shrink-0"
variant="segmented"
value={[diffLayout]}
onValueChange={(value) => {
const next = value[0];
if (next === "stacked" || next === "split") {
updateClientSettings({ diffLayout: next });
}
}}
>
<PilcrowIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{ignoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
</TooltipPopup>
</Tooltip>
<Toggle aria-label="Stacked diff view" value="stacked">
<Rows3Icon className="size-3.5" />
</Toggle>
<Toggle aria-label="Split diff view" value="split">
<Columns2Icon className="size-3.5" />
</Toggle>
</ToggleGroup>
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={wordWrap ? "Disable diff line wrapping" : "Enable diff line wrapping"}
variant="ghost"
size="sm"
pressed={wordWrap}
onPressedChange={(pressed) => {
setWordWrap(Boolean(pressed));
}}
/>
}
>
<TextWrapIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{wordWrap ? "Disable line wrapping" : "Enable line wrapping"}
</TooltipPopup>
</Tooltip>
</div>
{fileKeys.length > 0 ? (
<Tooltip>
<TooltipTrigger
@@ -1271,45 +1362,6 @@ function PullRequestCodeTab({
</TooltipPopup>
</Tooltip>
) : null}
<ToggleGroup
aria-label="Diff layout"
className="shrink-0"
variant="segmented"
value={[diffLayout]}
onValueChange={(value) => {
const next = value[0];
if (next === "stacked" || next === "split") {
updateClientSettings({ diffLayout: next });
}
}}
>
<Toggle aria-label="Stacked diff view" value="stacked">
<Rows3Icon className="size-3.5" />
</Toggle>
<Toggle aria-label="Split diff view" value="split">
<Columns2Icon className="size-3.5" />
</Toggle>
</ToggleGroup>
<Tooltip>
<TooltipTrigger
render={
<Toggle
aria-label={wordWrap ? "Disable diff line wrapping" : "Enable diff line wrapping"}
variant="ghost"
size="sm"
pressed={wordWrap}
onPressedChange={(pressed) => {
setWordWrap(Boolean(pressed));
}}
/>
}
>
<TextWrapIcon className="size-3.5" />
</TooltipTrigger>
<TooltipPopup side="top">
{wordWrap ? "Disable line wrapping" : "Enable line wrapping"}
</TooltipPopup>
</Tooltip>
{fileKeys.length > 0 ? (
<Tooltip>
<TooltipTrigger