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)}