Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(issues): make the unsubscribe menu items actually unsubscribe (MUL-5710) (#6367)

Naiyuan Qing5566612074a2
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index 73cb2b978a..dae29a63f2 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -1,5 +1,5 @@
import { forwardRef, useEffect, useRef, useState, useImperativeHandle } from "react";
-import { describe, it, expect, vi, beforeEach } from "vitest";
+import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import type { Issue, Label, TimelineEntry } from "@multica/core/types";
@@ -272,6 +272,7 @@ const mockApiObj = vi.hoisted(() => ({
listIssueSubscribers: vi.fn().mockResolvedValue([]),
subscribeToIssue: vi.fn().mockResolvedValue(undefined),
unsubscribeFromIssue: vi.fn().mockResolvedValue(undefined),
+ unsubscribeFromIssueSubtree: vi.fn().mockResolvedValue(undefined),
getActiveTasksForIssue: vi.fn().mockResolvedValue({ tasks: [] }),
listTasksByIssue: vi.fn().mockResolvedValue([]),
rerunIssue: vi.fn(),
@@ -1677,6 +1678,75 @@ describe("IssueDetail (shared)", () => {
expect(due.closest("span")?.className).toContain("text-muted-foreground");
});
});
+
+ // Deliberately drives the real Base UI DropdownMenu rather than a stub: the
+ // bug these tests pin (MUL-5710) was a handler wired to `onSelect`, which
+ // typechecks because Menu.Item's props extend the whole div attribute set,
+ // then lands on the DOM as the native text-selection event and never fires.
+ // Only the real menu reproduces that; any hand-rolled mock hides it.
+ describe("unsubscribe menu", () => {
+ const subscribedAsMember = [
+ {
+ issue_id: "issue-1",
+ user_type: "member" as const,
+ user_id: "user-1",
+ reason: "manual" as const,
+ created_at: "2026-01-01T00:00:00Z",
+ },
+ ];
+
+ beforeEach(() => {
+ mockApiObj.listIssueSubscribers.mockResolvedValue(subscribedAsMember);
+ });
+
+ // Base UI portals the popup onto document.body; RTL unmounts it, but wipe
+ // the body too so a leftover portal can't duplicate menu item names.
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ async function openUnsubscribeMenu() {
+ renderIssueDetail();
+ fireEvent.click(await screen.findByText("Unsubscribe"));
+ return screen.findByRole("menu");
+ }
+
+ it("unsubscribes the current member when the single-issue item is clicked", async () => {
+ await openUnsubscribeMenu();
+
+ fireEvent.click(
+ screen.getByRole("menuitem", { name: "Unsubscribe from this issue" }),
+ );
+
+ await waitFor(() =>
+ expect(mockApiObj.unsubscribeFromIssue).toHaveBeenCalledWith(
+ "issue-1",
+ "user-1",
+ "member",
+ ),
+ );
+ expect(mockApiObj.unsubscribeFromIssueSubtree).not.toHaveBeenCalled();
+ });
+
+ it("unsubscribes from the whole subtree when the subtree item is clicked", async () => {
+ await openUnsubscribeMenu();
+
+ fireEvent.click(
+ screen.getByRole("menuitem", {
+ name: "Unsubscribe from this issue and its sub-issues",
+ }),
+ );
+
+ await waitFor(() =>
+ expect(mockApiObj.unsubscribeFromIssueSubtree).toHaveBeenCalledWith(
+ "issue-1",
+ "user-1",
+ "member",
+ ),
+ );
+ expect(mockApiObj.unsubscribeFromIssue).not.toHaveBeenCalled();
+ });
+ });
});
describe("groupSubIssuesByStage", () => {
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index f989bcb185..ebefdcc17e 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -2651,11 +2651,17 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
<DropdownMenuTrigger className="text-caption text-muted-foreground hover:text-foreground transition-colors">
{t(($) => $.detail.unsubscribe)}
</DropdownMenuTrigger>
+ {/* onClick, not onSelect: Base UI's Menu.Item exposes no
+ onSelect (that is the Radix spelling), and because its
+ props extend the full div attribute set, an onSelect
+ typechecks and silently lands on the DOM node as the
+ native text-selection event — the handler never runs
+ (MUL-5710). */}
<DropdownMenuContent align="end">
- <DropdownMenuItem onSelect={handleToggleSubscribe}>
+ <DropdownMenuItem onClick={handleToggleSubscribe}>
{t(($) => $.detail.unsubscribe_this)}
</DropdownMenuItem>
- <DropdownMenuItem onSelect={handleUnsubscribeSubtree}>
+ <DropdownMenuItem onClick={handleUnsubscribeSubtree}>
{t(($) => $.detail.unsubscribe_subtree)}
</DropdownMenuItem>
</DropdownMenuContent>