Skip to content
TypeScript

fix(web): multi-PR badges open the linked pull requests panel (#13211)

oliver0fcd5f906114
diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsx
index 17199bbf337..c28bb475281 100644
--- a/apps/web/src/components/BranchToolbarBranchSelector.tsx
+++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx
@@ -793,7 +793,7 @@ export function BranchToolbarBranchSelector({
number={prNumber}
url={prUrl}
status={displayedPrStatus}
- onOpenStack={() => useRightPanelStore.getState().open(threadRef, "pull-requests")}
+ onOpenList={() => useRightPanelStore.getState().open(threadRef, "pull-requests")}
onOpenPullRequest={(event) => {
if (prUrl) openPrLink(event, prUrl);
}}
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 90f65ea2b94..7b9e0e545d5 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1515,11 +1515,12 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
const accessibleTitle = isRenaming ? null : <span className="sr-only">{thread.title}</span>;
// Stacks show their layer count; multiple unrelated links show their total count.
- // Plain clicks open T3; individual PR links also support opening the host in a new tab.
+ // Either opens the thread's pull requests tab; a single PR link opens that PR and still
+ // supports opening the host in a new tab.
const prBadgeShape = supportsMultiplePullRequests
? resolveThreadPullRequestBadge(thread.pullRequests)
: null;
- const handlePrStackClick = useCallback(() => {
+ const handlePrListClick = useCallback(() => {
useRightPanelStore.getState().open(threadRef, "pull-requests");
if (!props.isActive) onThreadActivate(threadRef);
}, [onThreadActivate, props.isActive, threadRef]);
@@ -1531,7 +1532,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
number={pr?.number ?? currentLinkedPr?.number}
url={pr?.url ?? currentLinkedPr?.url}
status={prStatus}
- onOpenStack={handlePrStackClick}
+ onOpenList={handlePrListClick}
onOpenPullRequest={handlePrClick}
/>
) : null;
diff --git a/apps/web/src/components/ThreadStatusIndicators.tsx b/apps/web/src/components/ThreadStatusIndicators.tsx
index 859650ca0a9..6ca601653f3 100644
--- a/apps/web/src/components/ThreadStatusIndicators.tsx
+++ b/apps/web/src/components/ThreadStatusIndicators.tsx
@@ -195,7 +195,8 @@ export function resolveThreadPullRequestBadgePresentation({
* The linked-PR badge shared by the sidebar and composer footer. The badge owns what it shows:
* the state glyph and number at the meta size, in the state's color. The caller owns the control
* it sits in through `render` (an inline link in a sidebar row, a toolbar control in the
- * composer), and the badge fills in the link or stack button behavior.
+ * composer), and the badge fills in the behavior: a single PR is a link to it, while a stack or
+ * several linked PRs is a button that opens the thread's pull requests tab.
*/
export function ThreadPullRequestBadgeControl({
render,
@@ -203,7 +204,7 @@ export function ThreadPullRequestBadgeControl({
number,
url,
status,
- onOpenStack,
+ onOpenList,
onOpenPullRequest,
}: {
render: ReactElement<{ render?: useRender.RenderProp }>;
@@ -211,7 +212,7 @@ export function ThreadPullRequestBadgeControl({
number?: number | undefined;
url?: string | undefined;
status: PrStatusIndicator | null;
- onOpenStack: () => void;
+ onOpenList: () => void;
onOpenPullRequest: (event: MouseEvent<HTMLElement>) => void;
}) {
const presentation = resolveThreadPullRequestBadgePresentation({ badge, number, url, status });
@@ -220,9 +221,9 @@ export function ThreadPullRequestBadgeControl({
<PullRequestBadge
render={render}
presentation={presentation}
- isStack={badge?.kind === "stack"}
+ opensList={badge !== null && (badge.kind === "stack" || badge.others > 0)}
url={url}
- onOpenStack={onOpenStack}
+ onOpenList={onOpenList}
onOpenPullRequest={onOpenPullRequest}
/>
);
@@ -231,26 +232,26 @@ export function ThreadPullRequestBadgeControl({
function PullRequestBadge({
render,
presentation,
- isStack,
+ opensList,
url,
- onOpenStack,
+ onOpenList,
onOpenPullRequest,
}: {
render: ReactElement<{ render?: useRender.RenderProp }>;
presentation: NonNullable<ReturnType<typeof resolveThreadPullRequestBadgePresentation>>;
- isStack: boolean;
+ opensList: boolean;
url: string | undefined;
- onOpenStack: () => void;
+ onOpenList: () => void;
onOpenPullRequest: (event: MouseEvent<HTMLElement>) => void;
}) {
- const onClick = isStack
+ const onClick = opensList
? (event: MouseEvent<HTMLElement>) => {
event.preventDefault();
event.stopPropagation();
- onOpenStack();
+ onOpenList();
}
: onOpenPullRequest;
- const element = isStack ? (
+ const element = opensList ? (
<button type="button" />
) : (
<a href={url} target="_blank" rel="noopener noreferrer" />
diff --git a/docs/user/source-control.md b/docs/user/source-control.md
index 0427f143c7d..306632d9ca6 100644
--- a/docs/user/source-control.md
+++ b/docs/user/source-control.md
@@ -164,7 +164,7 @@ on the Pull Requests page, **Link to thread** lets you search for an active thre
also lists the threads that link to it, including archived threads, so you can return to their context.
Thread badges show a stack's layer count or the current review number with a count of additional
-links. On mobile, the Git overview lists linked reviews and their stacks; tap a review to open it.
+links. Clicking a badge with more than one review opens the **Linked pull requests** panel. On mobile, the Git overview lists linked reviews and their stacks; tap a review to open it.
Linking and unlinking are available in the web and desktop clients.
The **Linked pull requests** panel lists every review and groups stacks. Unlink a review from its