fix(web): align pull request action menu rows (#6534)

Co-authored-by: Nickolas Kyryliuk <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-08-14 22:48:54 -04:00
1 parent 48ddb3d469
commit 8c628f1499
5 files changed
+74 -9

No files matched your search

@@ -103,6 +103,7 @@ import {
handoffPrompt,
handoffReviewComments,
pullRequestActionNeedsHostRefresh,
pullRequestActionMenuHasGroup,
pullRequestFindingKey,
pullRequestHandoffLabels,
readableFailure,
@@ -1033,6 +1034,26 @@ export function PullRequestDetailPanel({
: allowedMergeMethods.length > 0
? "merge"
: null;
// What the menu's action group holds. Named once so the separators around it are drawn from
// the same answer as its contents, rather than on the assumption that it has any.
const showsDraftToggle =
detail?.state === "open" &&
can(detail.isDraft ? "ready" : "draft") &&
!(detail.isDraft && primaryAction === "ready");
const showsAutoMerge =
detail?.state === "open" &&
((autoMergeArmed && can("disable-auto-merge")) ||
(!autoMergeArmed &&
!detail.isDraft &&
!conflicting &&
can("enable-auto-merge") &&
allowedMergeMethods.length > 0));
const showsMergeMethods =
detail?.state === "open" &&
can("merge") &&
!detail.isDraft &&
!conflicting &&
allowedMergeMethods.length > 1;
// The pull request number carries this state in the overview and the right-panel tab mirrors
// it. Conflicts keep their own row below: an open pull request remains green there.
const statePresentation = detail
@@ -1191,8 +1212,7 @@ export function PullRequestDetailPanel({
{/* Only where the button row could not take it: "Ready for review" on a
draft is the primary header button, so offering it here as well would
show the same action twice. */}
{can(detail.isDraft ? "ready" : "draft") &&
!(detail.isDraft && primaryAction === "ready") ? (
{showsDraftToggle ? (
<MenuItem
disabled={actionPending}
onClick={() => void perform(detail.isDraft ? "ready" : "draft")}
@@ -1236,12 +1256,12 @@ export function PullRequestDetailPanel({
Hidden while conflicting: every method would fail. */}
{/* Only where merging is on offer at all: a strategy to merge with is not
a choice for someone who may not merge. */}
{can("merge") &&
!detail.isDraft &&
!conflicting &&
allowedMergeMethods.length > 1 ? (
{showsMergeMethods ? (
<>
<MenuSeparator />
{/* Only below the draft control. A host with no draft of its own, or
a draft whose control is already the header button, would leave
this against the separator that opened the group. */}
{showsDraftToggle ? <MenuSeparator /> : null}
<MenuRadioGroup
value={selectedMergeMethod}
onValueChange={(method) =>
@@ -1261,7 +1281,13 @@ export function PullRequestDetailPanel({
</MenuRadioGroup>
</>
) : null}
<MenuSeparator />
{pullRequestActionMenuHasGroup(
showsDraftToggle,
showsAutoMerge,
showsMergeMethods,
) ? (
<MenuSeparator />
) : null}
</>
) : null}
<MenuItem onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}>
@@ -19,6 +19,7 @@ import {
isThreadOwnPullRequest,
orderPullRequestComments,
pullRequestActionNeedsHostRefresh,
pullRequestActionMenuHasGroup,
pullRequestFindingKey,
pullRequestHandoffLabels,
readableFailure,
@@ -53,6 +54,12 @@ const TIMELINE_SOURCE: Pick<
closedAt: null,
};
describe("pull request action menu", () => {
it("keeps the group divider when auto-merge is the only action", () => {
expect(pullRequestActionMenuHasGroup(false, true, false)).toBe(true);
});
});
describe("pull request state description", () => {
it("keeps draft and conflicts orthogonal to the terminal states", () => {
expect(describePullRequestState("open", true)).toBe("Draft");
@@ -57,6 +57,15 @@ export function pullRequestHandoffLabels(inThisThread: boolean) {
};
}
/** Whether the open pull-request action group contains at least one action. */
export function pullRequestActionMenuHasGroup(
showsDraftToggle: boolean,
showsAutoMerge: boolean,
showsMergeMethods: boolean,
): boolean {
return showsDraftToggle || showsAutoMerge || showsMergeMethods;
}
/** Plain-language state, shown beside the author. Conflicts are a merge signal, not a state. */
export function describePullRequestState(state: PullRequestState, isDraft: boolean): string {
if (state === "merged") return "Merged";
+23
View File
@@ -0,0 +1,23 @@
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vite-plus/test";
import { Menu, MenuRadioGroup, MenuRadioItem } from "./menu";
describe("menu radio item geometry", () => {
it("keeps radio-item icons on the same text grid as menu items", () => {
const html = renderToStaticMarkup(
<Menu>
<MenuRadioGroup value="merge">
<MenuRadioItem value="merge">
<span className="flex items-center gap-2">
<svg aria-hidden className="size-3.5" />
<span>Merge</span>
</span>
</MenuRadioItem>
</MenuRadioGroup>
</Menu>,
);
expect(html).toContain("-mx-0.5");
});
});
+1 -1
View File
@@ -166,7 +166,7 @@ function MenuRadioItem({
return (
<MenuPrimitive.RadioItem
className={cn(
"flex min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-pointer items-center rounded-sm px-2 py-1 text-base text-foreground outline-none data-checked:bg-foreground/[0.08] data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
"[&_svg]:-mx-0.5 flex min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-pointer items-center rounded-sm px-2 py-1 text-base text-foreground outline-none data-checked:bg-foreground/[0.08] data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
className,
)}
data-slot="menu-radio-item"