From a1bff13a5a7ff70989e4e64384200d8f6cf4fc5e Mon Sep 17 00:00:00 2001 From: Kalven Schraut Date: Tue, 15 Sep 2026 10:19:32 -0500 Subject: [PATCH] fix(web): related PRs menu no longer crashes in production builds Base UI's MenuGroupLabel throws when it has no Menu.Group ancestor. The "Related PRs" menu rendered its heading, notices, and status labels directly under the popup, so opening it in a production build surfaced Base UI error #31 as an app crash. Wrap those labels in MenuGroup like the rest of the file. Co-Authored-By: Claude Fable 5.1 --- .../pullRequest/PullRequestBranchMenu.tsx | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/apps/web/src/components/pullRequest/PullRequestBranchMenu.tsx b/apps/web/src/components/pullRequest/PullRequestBranchMenu.tsx index 3e07a754be4a..feb80a0c7573 100644 --- a/apps/web/src/components/pullRequest/PullRequestBranchMenu.tsx +++ b/apps/web/src/components/pullRequest/PullRequestBranchMenu.tsx @@ -1,6 +1,6 @@ import type { PullRequestRef } from "@t3tools/contracts"; import { CheckIcon, GitBranchIcon, TriangleAlertIcon } from "lucide-react"; -import { useState } from "react"; +import { useState, type ReactNode } from "react"; import { Button } from "../ui/button"; import { Menu, MenuGroup, MenuGroupLabel, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu"; @@ -32,6 +32,13 @@ export function PullRequestBranchMenu({ (navigation.status === "ready" && navigation.coverage !== "complete") ? "Some branch relationships may be missing." : null; + // `MenuGroupLabel` reads group context and throws without a `MenuGroup` ancestor, so + // every standalone heading or notice gets its own group. + const note = (text: ReactNode) => ( + + {text} + + ); const choices = (label: string, chips: ReadonlyArray) => chips.length > 0 ? ( @@ -85,32 +92,30 @@ export function PullRequestBranchMenu({ Pull requests related by their base and head branches - Inferred from branches - {notice ? {notice} : null} - {notice ? ( - - Retry branch lookup - - ) : null} + + Inferred from branches + {notice ? {notice} : null} + {notice ? ( + + Retry branch lookup + + ) : null} + {navigation.status === "ready" ? (
- {navigation.cycleBefore || navigation.cycleAfter ? ( - Branch cycle detected. Ordering stops at the cycle. - ) : null} - {navigation.parentAmbiguous ? ( - Parent is ambiguous. - ) : null} - {navigation.truncatedAfter ? ( - - Open #{navigation.path.at(-1)?.number} to see more above. - - ) : null} + {navigation.cycleBefore || navigation.cycleAfter + ? note("Branch cycle detected. Ordering stops at the cycle.") + : null} + {navigation.parentAmbiguous ? note("Parent is ambiguous.") : null} + {navigation.truncatedAfter + ? note(`Open #${navigation.path.at(-1)?.number} to see more above.`) + : null} {choices("Branch chain", navigation.path.toReversed())} - {navigation.truncatedBefore ? ( - Open #{navigation.path[0]?.number} to see more below. - ) : navigation.rootBase ? ( - ↳ {navigation.rootBase} - ) : null} + {navigation.truncatedBefore + ? note(`Open #${navigation.path[0]?.number} to see more below.`) + : navigation.rootBase + ? note(`↳ ${navigation.rootBase}`) + : null} {choices(`Children of #${navigation.path.at(-1)?.number}`, navigation.children)} {choices("Siblings", navigation.siblings)} {choices("Possible parents", navigation.possibleParents)}