Skip to content

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

Go

MUL-8425 fix(issues): open Assignee as a submenu in issue menus (#9752)

Jiayuan Zhang97056cfca998
diff --git a/packages/ui/components/ui/context-menu.tsx b/packages/ui/components/ui/context-menu.tsx
index ba0923e071..f12426b965 100644
--- a/packages/ui/components/ui/context-menu.tsx
+++ b/packages/ui/components/ui/context-menu.tsx
@@ -130,7 +130,7 @@ function ContextMenuSubTrigger({
data-slot="context-menu-sub-trigger"
data-inset={inset}
className={cn(
- "flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-body outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
diff --git a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx
index da0e879506..65dd233464 100644
--- a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx
+++ b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx
@@ -1,5 +1,6 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import type { AgentTask, Issue } from "@multica/core/types";
import { I18nProvider } from "@multica/core/i18n/react";
@@ -75,10 +76,13 @@ vi.mock("@multica/core/pins", () => ({
useDeletePin: () => ({ mutate: vi.fn() }),
}));
-const { cancelRunMock } = vi.hoisted(() => ({ cancelRunMock: vi.fn() }));
+const { cancelRunMock, updateIssueMock } = vi.hoisted(() => ({
+ cancelRunMock: vi.fn(),
+ updateIssueMock: vi.fn(),
+}));
vi.mock("@multica/core/issues/mutations", () => ({
- useUpdateIssue: () => ({ mutate: vi.fn() }),
+ useUpdateIssue: () => ({ mutate: updateIssueMock }),
useCancelIssueRun: () => ({ mutateAsync: cancelRunMock }),
}));
@@ -203,6 +207,7 @@ beforeEach(() => {
apiMocks.getAgentTaskSnapshot.mockResolvedValue([]);
cancelRunMock.mockReset();
cancelRunMock.mockResolvedValue(undefined);
+ updateIssueMock.mockReset();
});
describe("IssueActionsDropdown", () => {
@@ -253,7 +258,7 @@ describe("IssueActionsDropdown", () => {
expect(labels.slice(0, 3)).toEqual(["Rename issue", "Create sub-issue", "Status"]);
});
- it("clicking the Assignee item opens the shared AssigneePicker popover", async () => {
+ it("opens Assignee as a submenu holding the shared assignee picker", async () => {
render(
wrap(
<IssueActionsDropdown
@@ -266,14 +271,19 @@ describe("IssueActionsDropdown", () => {
fireEvent.click(screen.getByTestId("trigger"));
fireEvent.click(await screen.findByText("Assignee"));
- // The shared picker exposes a search input and renders the workspace
- // member under a "Members" group — both come from `AssigneePicker`, not
- // the legacy submenu (which had neither).
+ // The search box and the "Members" group come from the shared assignee
+ // picker, so the submenu offers what every other assignee entry point does.
expect(
await screen.findByPlaceholderText("Assign to..."),
).toBeInTheDocument();
expect(await screen.findByText("Members")).toBeInTheDocument();
- expect(await screen.findByText("Test User")).toBeInTheDocument();
+ fireEvent.click(await screen.findByText("Test User"));
+
+ expect(updateIssueMock).toHaveBeenCalledWith(
+ { id: "issue-1", assignee_type: "member", assignee_id: "user-1" },
+ expect.anything(),
+ );
+ await waitFor(() => expect(screen.queryByText("Status")).not.toBeInTheDocument());
});
it("shows 'Remove parent issue' in the Relations submenu only when the issue has a parent", async () => {
@@ -513,6 +523,36 @@ describe("IssueActionsContextMenu", () => {
expect(screen.getByText("Open in new tab")).toBeInTheDocument();
expect(screen.getByText("Delete issue")).toBeInTheDocument();
});
+
+ it("keeps typed keys in the assignee search box and assigns the match on Enter", async () => {
+ const user = userEvent.setup();
+ render(
+ wrap(
+ <IssueContextMenuProvider>
+ <IssueActionsContextMenu issue={mockIssue}>
+ <div data-testid="row">Row</div>
+ </IssueActionsContextMenu>
+ </IssueContextMenuProvider>,
+ ),
+ );
+
+ fireEvent.contextMenu(screen.getByTestId("row"));
+ await user.click(await screen.findByText("Assignee"));
+ const search = await screen.findByPlaceholderText("Assign to...");
+ await screen.findByText("Test User");
+ await waitFor(() => expect(search).toHaveFocus());
+
+ // The menu's typeahead would otherwise swallow these keys.
+ await user.keyboard("test");
+ expect(search).toHaveValue("test");
+ await user.keyboard("{Enter}");
+
+ expect(updateIssueMock).toHaveBeenCalledWith(
+ { id: "issue-1", assignee_type: "member", assignee_id: "user-1" },
+ expect.anything(),
+ );
+ await waitFor(() => expect(screen.queryByText("Rename issue")).not.toBeInTheDocument());
+ });
});
describe("Sidebar variant (MUL-8425)", () => {
diff --git a/packages/views/issues/actions/issue-actions-context-menu.tsx b/packages/views/issues/actions/issue-actions-context-menu.tsx
index ac780ce33b..3c2f8d74fe 100644
--- a/packages/views/issues/actions/issue-actions-context-menu.tsx
+++ b/packages/views/issues/actions/issue-actions-context-menu.tsx
@@ -23,7 +23,6 @@ import {
IssueActionsMenuItems,
contextPrimitives,
} from "./issue-actions-menu-items";
-import { AssigneePicker } from "../components/pickers";
import { TerminateTaskConfirmDialog } from "../components/terminate-task-confirm-dialog";
import { useT } from "../../i18n";
@@ -119,7 +118,6 @@ function IssueContextMenuSingleton({
variant: IssueContextMenuVariant;
}) {
const actions = useIssueActions(issue);
- const [assigneeOpen, setAssigneeOpen] = useState(false);
const [stopTask, setStopTask] = useState<AgentTask | null>(null);
// Point-sized virtual anchor at the right-click position — replaces the
@@ -147,7 +145,7 @@ function IssueContextMenuSingleton({
issue={issue}
actions={actions}
primitives={contextPrimitives}
- onOpenAssignee={() => setAssigneeOpen(true)}
+ onClose={() => onOpenChange(false)}
variant={variant}
onStopRun={setStopTask}
/>
@@ -160,33 +158,6 @@ function IssueContextMenuSingleton({
onClose={() => setStopTask(null)}
/>
)}
-
- {/* Mount the picker only once the user actually opens it, anchored at
- the right-click position so it opens where the context menu just
- was instead of jumping to the row's top-left corner. */}
- {assigneeOpen && (
- <AssigneePicker
- assigneeType={issue.assignee_type}
- assigneeId={issue.assignee_id}
- onUpdate={actions.updateField}
- open={assigneeOpen}
- onOpenChange={setAssigneeOpen}
- triggerRender={
- <span
- aria-hidden
- className="pointer-events-none fixed"
- style={{
- left: position.x,
- top: position.y,
- width: 0,
- height: 0,
- }}
- />
- }
- trigger={<span />}
- align="start"
- />
- )}
</>
);
}
diff --git a/packages/views/issues/actions/issue-actions-dropdown.tsx b/packages/views/issues/actions/issue-actions-dropdown.tsx
index c65d635d27..ad241c829c 100644
--- a/packages/views/issues/actions/issue-actions-dropdown.tsx
+++ b/packages/views/issues/actions/issue-actions-dropdown.tsx
@@ -12,7 +12,6 @@ import {
IssueActionsMenuItems,
dropdownPrimitives,
} from "./issue-actions-menu-items";
-import { AssigneePicker } from "../components/pickers";
interface IssueActionsDropdownProps {
issue: Issue;
@@ -31,46 +30,20 @@ export function IssueActionsDropdown({
onDeletedFallbackPath,
}: IssueActionsDropdownProps) {
const actions = useIssueActions(issue);
- const [assigneeOpen, setAssigneeOpen] = useState(false);
+ const [open, setOpen] = useState(false);
- // The outer `relative inline-flex` is the picker's anchor box: the
- // absolute, pointer-events-none span inside `triggerRender` fills it, so
- // the popover positions itself relative to the dropdown's 3-dot button
- // without us having to thread a ref through Base UI's anchor API.
return (
- <span className="relative inline-flex">
- <DropdownMenu>
- <DropdownMenuTrigger render={trigger} />
- <DropdownMenuContent align={align} className="w-auto">
- <IssueActionsMenuItems
- issue={issue}
- actions={actions}
- primitives={dropdownPrimitives}
- onOpenAssignee={() => setAssigneeOpen(true)}
- onDeletedFallbackPath={onDeletedFallbackPath}
- />
- </DropdownMenuContent>
- </DropdownMenu>
- {/* Mount the picker only once the user actually opens it. Otherwise
- every row in a list/board would subscribe to members/agents/squads
- /frequency queries on mount, multiplying memory + render cost. */}
- {assigneeOpen && (
- <AssigneePicker
- assigneeType={issue.assignee_type}
- assigneeId={issue.assignee_id}
- onUpdate={actions.updateField}
- open={assigneeOpen}
- onOpenChange={setAssigneeOpen}
- triggerRender={
- <span
- aria-hidden
- className="pointer-events-none absolute inset-0"
- />
- }
- trigger={<span />}
- align={align}
+ <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenuTrigger render={trigger} />
+ <DropdownMenuContent align={align} className="w-auto">
+ <IssueActionsMenuItems
+ issue={issue}
+ actions={actions}
+ primitives={dropdownPrimitives}
+ onClose={() => setOpen(false)}
+ onDeletedFallbackPath={onDeletedFallbackPath}
/>
- )}
- </span>
+ </DropdownMenuContent>
+ </DropdownMenu>
);
}
diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsx
index 4f2bd6b02b..c10e4d9a4b 100644
--- a/packages/views/issues/actions/issue-actions-menu-items.tsx
+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useCallback, useMemo, type ReactNode } from "react";
+import { useCallback, useMemo, useRef, type ReactNode } from "react";
import { useQuery } from "@tanstack/react-query";
import { toast } from "sonner";
import {
@@ -44,6 +44,7 @@ import { issueKeys } from "@multica/core/issues/queries";
import { StatusIcon } from "../components/status-icon";
import { PriorityIcon } from "../components/priority-icon";
import { selectIssueTasks } from "../surface/activity";
+import { AssigneePickerPanel } from "../components/pickers";
import {
DropdownMenuItem,
DropdownMenuSub,
@@ -97,11 +98,9 @@ interface IssueActionsMenuItemsProps {
issue: Issue;
actions: UseIssueActionsResult;
primitives: MenuPrimitives;
- /** Called when the user clicks the Assignee menu item. The parent should
- * close the surrounding menu and open the shared `AssigneePicker` popover.
- * Decoupled this way so the same item can drive both the dropdown
- * (3-dot button) and the context menu (right-click) wrappers. */
- onOpenAssignee: () => void;
+ /** Closes the surrounding menu. Menu items close it themselves; the
+ * assignee list is not made of menu items, so it calls this after a pick. */
+ onClose: () => void;
/** If set, leave the page after the issue is deleted (used by the detail
* page, which renders the issue being deleted). The delete modal goes back
* to the list the user came from and only falls back to this path when
@@ -121,7 +120,7 @@ export function IssueActionsMenuItems({
issue,
actions,
primitives: P,
- onOpenAssignee,
+ onClose,
onDeletedFallbackPath,
variant = "full",
onStopRun,
@@ -312,18 +311,29 @@ export function IssueActionsMenuItems({
</P.SubContent>
</P.Sub>
- {/* Assignee — closes this menu and hands off to the shared
- AssigneePicker (members + agents + squads, with search and
- permission checks). Keeps a single source of truth for the
- assignee UX across detail sidebar, board cards, and right-click /
- 3-dot menus. */}
- <P.Item onClick={onOpenAssignee}>
- <UserMinus className="h-3.5 w-3.5" />
- <ItemLabel
- label={t(($) => $.actions.assignee)}
- value={sidebar ? <AssigneeName issue={issue} /> : undefined}
- />
- </P.Item>
+ {/* Assignee — a submenu like Status and Priority, filled with the
+ shared assignee picker's own list (members + agents + squads, with
+ search and permission checks) rather than menu items of its own, so
+ every entry point offers the same choices. (MUL-2157) */}
+ <P.Sub>
+ <P.SubTrigger>
+ <UserMinus className="h-3.5 w-3.5" />
+ <ItemLabel
+ label={t(($) => $.actions.assignee)}
+ value={sidebar ? <AssigneeName issue={issue} /> : undefined}
+ />
+ </P.SubTrigger>
+ <P.SubContent className="w-64 p-0">
+ <SubmenuPanel>
+ <AssigneePickerPanel
+ assigneeType={issue.assignee_type}
+ assigneeId={issue.assignee_id}
+ onUpdate={updateField}
+ onPicked={onClose}
+ />
+ </SubmenuPanel>
+ </P.SubContent>
+ </P.Sub>
{!sidebar && (
<>
@@ -497,6 +507,28 @@ function ItemLabel({ label, value }: { label: string; value?: ReactNode }) {
);
}
+/** Hosts a search box and list inside a submenu. The menu's typeahead and
+ * arrow-key navigation would otherwise take the keys typed into the search
+ * box; Escape and Tab still reach the menu so it can close. */
+function SubmenuPanel({ children }: { children: ReactNode }) {
+ const ref = useRef<HTMLDivElement>(null);
+ return (
+ <div
+ ref={ref}
+ onKeyDown={(e) => {
+ // Hold the height from the first keystroke: a shorter, filtered list
+ // would re-position a submenu shifted to fit the viewport, moving the
+ // search box while the user types in it.
+ const el = ref.current;
+ if (el && !el.style.minHeight) el.style.minHeight = `${el.offsetHeight}px`;
+ if (e.key !== "Escape" && e.key !== "Tab") e.stopPropagation();
+ }}
+ >
+ {children}
+ </div>
+ );
+}
+
function AssigneeName({ issue }: { issue: Issue }) {
const { t } = useT("issues");
const { getActorName } = useActorName();
diff --git a/packages/views/issues/components/pickers/assignee-picker.tsx b/packages/views/issues/components/pickers/assignee-picker.tsx
index 351e9ad9d6..0a379385c4 100644
--- a/packages/views/issues/components/pickers/assignee-picker.tsx
+++ b/packages/views/issues/components/pickers/assignee-picker.tsx
@@ -14,6 +14,7 @@ import { ActorAvatar } from "../../../common/actor-avatar";
import { DeferredPopup } from "../../../common/deferred-popup";
import {
PropertyPicker,
+ PickerPanel,
PickerItem,
PickerSection,
PickerEmpty,
@@ -109,13 +110,102 @@ function AssigneePickerImpl({
const open = controlledOpen ?? internalOpen;
const setOpen = controlledOnOpenChange ?? setInternalOpen;
const [filter, setFilter] = useState("");
+ const choices = useAssigneeChoices(filter);
+ const { getActorName } = useActorName();
+
+ const triggerLabel =
+ assigneeType && assigneeId
+ ? getActorName(assigneeType, assigneeId)
+ : t(($) => $.pickers.assignee.trigger_unassigned);
+
+ return (
+ <PropertyPicker
+ open={open}
+ onOpenChange={(v: boolean) => {
+ setOpen(v);
+ if (!v) setFilter("");
+ }}
+ width="w-64"
+ align={align}
+ searchable
+ searchPlaceholder={t(($) => $.pickers.assignee.search_placeholder)}
+ onSearchChange={setFilter}
+ triggerRender={triggerRender}
+ tooltip={tooltip}
+ trigger={
+ customTrigger ? customTrigger : assigneeType && assigneeId ? (
+ <>
+ <ActorAvatar actorType={assigneeType} actorId={assigneeId} size="sm" enableHoverCard showStatusDot />
+ <span className="truncate">{triggerLabel}</span>
+ </>
+ ) : (
+ <span className="text-muted-foreground">{t(($) => $.pickers.assignee.trigger_unassigned)}</span>
+ )
+ }
+ >
+ <AssigneeOptions
+ choices={choices}
+ filter={filter}
+ assigneeType={assigneeType}
+ assigneeId={assigneeId}
+ mixed={mixed}
+ onPick={(updates) => {
+ onUpdate(updates);
+ setOpen(false);
+ }}
+ />
+ </PropertyPicker>
+ );
+}
+
+/**
+ * The assignee picker's search box and list without the popover, for hosting
+ * inside a menu. `onPicked` runs after the choice is applied so the host can
+ * close itself.
+ */
+export function AssigneePickerPanel({
+ assigneeType,
+ assigneeId,
+ onUpdate,
+ onPicked,
+}: {
+ assigneeType: IssueAssigneeType | null;
+ assigneeId: string | null;
+ onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
+ onPicked: () => void;
+}) {
+ const { t } = useT("issues");
+ const [filter, setFilter] = useState("");
+ const choices = useAssigneeChoices(filter);
+
+ return (
+ <PickerPanel
+ searchable
+ autoFocusSearch
+ searchPlaceholder={t(($) => $.pickers.assignee.search_placeholder)}
+ onSearchChange={setFilter}
+ >
+ <AssigneeOptions
+ choices={choices}
+ filter={filter}
+ assigneeType={assigneeType}
+ assigneeId={assigneeId}
+ onPick={(updates) => {
+ onUpdate(updates);
+ onPicked();
+ }}
+ />
+ </PickerPanel>
+ );
+}
+
+function useAssigneeChoices(filter: string) {
const user = useAuthStore((s) => s.user);
const wsId = useWorkspaceId();
const { data: members = [] } = useQuery(memberListOptions(wsId));
const { data: agents = [] } = useQuery(agentListOptions(wsId));
const { data: squads = [] } = useQuery(squadListOptions(wsId));
const { data: frequency = [] } = useQuery(assigneeFrequencyOptions(wsId));
- const { getActorName } = useActorName();
const currentMember = members.find((m) => m.user_id === user?.id);
const memberRole = currentMember?.role;
@@ -147,49 +237,47 @@ function AssigneePickerImpl({
.map((agent) => agent.id),
);
+ return {
+ userId: user?.id ?? null,
+ memberRole,
+ filteredMembers,
+ filteredAgents,
+ filteredSquads,
+ runnableAgentIds,
+ };
+}
+
+function AssigneeOptions({
+ choices,
+ filter,
+ assigneeType,
+ assigneeId,
+ mixed = false,
+ onPick,
+}: {
+ choices: ReturnType<typeof useAssigneeChoices>;
+ filter: string;
+ assigneeType: IssueAssigneeType | null;
+ assigneeId: string | null;
+ mixed?: boolean;
+ onPick: (updates: Partial<UpdateIssueRequest>) => void;
+}) {
+ const { t } = useT("issues");
+ const { userId, memberRole, filteredMembers, filteredAgents, filteredSquads, runnableAgentIds } =
+ choices;
+
const isSelected = (type: string, id: string) =>
assigneeType === type && assigneeId === id;
- const triggerLabel =
- assigneeType && assigneeId
- ? getActorName(assigneeType, assigneeId)
- : t(($) => $.pickers.assignee.trigger_unassigned);
-
return (
- <PropertyPicker
- open={open}
- onOpenChange={(v: boolean) => {
- setOpen(v);
- if (!v) setFilter("");
- }}
- width="w-64"
- align={align}
- searchable
- searchPlaceholder={t(($) => $.pickers.assignee.search_placeholder)}
- onSearchChange={setFilter}
- triggerRender={triggerRender}
- tooltip={tooltip}
- trigger={
- customTrigger ? customTrigger : assigneeType && assigneeId ? (
- <>
- <ActorAvatar actorType={assigneeType} actorId={assigneeId} size="sm" enableHoverCard showStatusDot />
- <span className="truncate">{triggerLabel}</span>
- </>
- ) : (
- <span className="text-muted-foreground">{t(($) => $.pickers.assignee.trigger_unassigned)}</span>
- )
- }
- >
+ <>
{/* Unassigned — always the first row, search active or not. Every
picker in the app puts the empty value there, so "clear this field"
never moves. */}
<PickerItem
emptyValue
selected={!mixed && !assigneeType && !assigneeId}
- onClick={() => {
- onUpdate({ assignee_type: null, assignee_id: null });
- setOpen(false);
- }}
+ onClick={() => onPick({ assignee_type: null, assignee_id: null })}
>
<UserMinus className="h-3.5 w-3.5 text-muted-foreground" />
<span className="text-muted-foreground">{t(($) => $.pickers.assignee.trigger_unassigned)}</span>
@@ -202,13 +290,12 @@ function AssigneePickerImpl({
<PickerItem
key={m.user_id}
selected={isSelected("member", m.user_id)}
- onClick={() => {
- onUpdate({
+ onClick={() =>
+ onPick({
assignee_type: "member",
assignee_id: m.user_id,
- });
- setOpen(false);
- }}
+ })
+ }
>
<ActorAvatar actorType="member" actorId={m.user_id} size="sm" />
<span className="truncate">{m.name}</span>
@@ -222,7 +309,7 @@ function AssigneePickerImpl({
<PickerSection label={t(($) => $.pickers.assignee.agents_group)}>
{filteredAgents.map((a) => {
const decision = canAssignAgentToIssue(a, {
- userId: user?.id ?? null,
+ userId,
role:
memberRole === "owner" ||
memberRole === "admin" ||
@@ -246,11 +333,10 @@ function AssigneePickerImpl({
}
onClick={() => {
if (!allowed) return;
- onUpdate({
+ onPick({
assignee_type: "agent",
assignee_id: a.id,
});
- setOpen(false);
}}
>
<ActorAvatar actorType="agent" actorId={a.id} size="sm" showStatusDot />
@@ -282,11 +368,10 @@ function AssigneePickerImpl({
}
onClick={() => {
if (!runtimeBound) return;
- onUpdate({
+ onPick({
assignee_type: "squad",
assignee_id: s.id,
});
- setOpen(false);
}}
>
<ActorAvatar actorType="squad" actorId={s.id} size="sm" />
@@ -301,6 +386,6 @@ function AssigneePickerImpl({
filteredAgents.length === 0 &&
filteredSquads.length === 0 &&
filter && <PickerEmpty />}
- </PropertyPicker>
+ </>
);
}
diff --git a/packages/views/issues/components/pickers/index.ts b/packages/views/issues/components/pickers/index.ts
index 51e7225613..6ae8782d0d 100644
--- a/packages/views/issues/components/pickers/index.ts
+++ b/packages/views/issues/components/pickers/index.ts
@@ -2,7 +2,7 @@ export { PropertyPicker, PickerItem, PickerSection, PickerEmpty } from "./proper
export { StatusPicker } from "./status-picker";
export { PriorityPicker } from "./priority-picker";
export { StagePicker } from "./stage-picker";
-export { AssigneePicker, canAssignAgent } from "./assignee-picker";
+export { AssigneePicker, AssigneePickerPanel, canAssignAgent } from "./assignee-picker";
export { StartDatePicker } from "./start-date-picker";
export { DueDatePicker } from "./due-date-picker";
export { LabelPicker } from "./label-picker";
diff --git a/packages/views/issues/components/pickers/property-picker.tsx b/packages/views/issues/components/pickers/property-picker.tsx
index a9d99c6bc2..ea531b1955 100644
--- a/packages/views/issues/components/pickers/property-picker.tsx
+++ b/packages/views/issues/components/pickers/property-picker.tsx
@@ -84,18 +84,80 @@ export function PropertyPicker({
* selectable listbox options.
*/
footer?: React.ReactNode;
+}) {
+ const [tooltipHover, setTooltipHover] = useState(false);
+ // Show the tooltip only while the trigger is hovered AND the popover is
+ // closed — avoids the awkward state where the tooltip floats next to (or
+ // on top of) the popover that just opened on click.
+ const tooltipOpen = !!tooltip && tooltipHover && !open;
+
+ const popoverTrigger = (
+ <PopoverTrigger
+ nativeButton={nativeButton}
+ className={triggerRender ? undefined : PICKER_TRIGGER_CLASS}
+ render={triggerRender}
+ >
+ {trigger}
+ </PopoverTrigger>
+ );
+
+ return (
+ <Popover open={open} onOpenChange={onOpenChange}>
+ {tooltip ? (
+ <Tooltip open={tooltipOpen} onOpenChange={setTooltipHover}>
+ <TooltipTrigger render={popoverTrigger} />
+ <TooltipContent side="top">{tooltip}</TooltipContent>
+ </Tooltip>
+ ) : (
+ popoverTrigger
+ )}
+ <PopoverContent align={align} side={side} className={`${width} gap-0 p-0`}>
+ <PickerPanel
+ open={open}
+ searchable={searchable}
+ searchPlaceholder={searchPlaceholder}
+ onSearchChange={onSearchChange}
+ header={header}
+ footer={footer}
+ >
+ {children}
+ </PickerPanel>
+ </PopoverContent>
+ </Popover>
+ );
+}
+
+// PickerPanel — a picker's search box and keyboard-navigable list, without
+// the popover. PropertyPicker wraps it; menus host it in a submenu.
+
+export function PickerPanel({
+ open = true,
+ searchable = false,
+ searchPlaceholder,
+ onSearchChange,
+ autoFocusSearch = false,
+ header,
+ children,
+ footer,
+}: {
+ /** The surrounding surface's open state; closing it resets the search. */
+ open?: boolean;
+ searchable?: boolean;
+ searchPlaceholder?: string | undefined;
+ onSearchChange?: (query: string) => void;
+ /** Focus the search box on mount. A popover moves focus in by itself; a
+ * submenu does not. */
+ autoFocusSearch?: boolean;
+ header?: React.ReactNode;
+ children: React.ReactNode;
+ footer?: React.ReactNode;
}) {
const { t } = useT("issues");
const placeholder = searchPlaceholder ?? t(($) => $.filters.placeholder);
const filterAria = t(($) => $.pickers.filter_options_aria);
const [query, setQuery] = useState("");
const [highlightedIndex, setHighlightedIndex] = useState(-1);
- const [tooltipHover, setTooltipHover] = useState(false);
const listRef = useRef<HTMLDivElement>(null);
- // Show the tooltip only while the trigger is hovered AND the popover is
- // closed — avoids the awkward state where the tooltip floats next to (or
- // on top of) the popover that just opened on click.
- const tooltipOpen = !!tooltip && tooltipHover && !open;
const getItems = useCallback(() => {
if (!listRef.current) return [];
@@ -182,49 +244,30 @@ export function PropertyPicker({
[getItems, highlightedIndex],
);
- const popoverTrigger = (
- <PopoverTrigger
- nativeButton={nativeButton}
- className={triggerRender ? undefined : PICKER_TRIGGER_CLASS}
- render={triggerRender}
- >
- {trigger}
- </PopoverTrigger>
- );
-
return (
- <Popover open={open} onOpenChange={onOpenChange}>
- {tooltip ? (
- <Tooltip open={tooltipOpen} onOpenChange={setTooltipHover}>
- <TooltipTrigger render={popoverTrigger} />
- <TooltipContent side="top">{tooltip}</TooltipContent>
- </Tooltip>
- ) : (
- popoverTrigger
+ <>
+ {searchable && (
+ <div className="px-2 py-1.5 border-b">
+ <input
+ type="text"
+ value={query}
+ onChange={(e) => {
+ setQuery(e.target.value);
+ pendingSearchHighlight.current = true;
+ onSearchChange?.(e.target.value);
+ }}
+ onKeyDown={handleKeyDown}
+ placeholder={placeholder}
+ aria-label={filterAria}
+ autoFocus={autoFocusSearch}
+ className="w-full bg-transparent text-body placeholder:text-muted-foreground outline-none"
+ />
+ </div>
)}
- <PopoverContent align={align} side={side} className={`${width} gap-0 p-0`}>
- {searchable && (
- <div className="px-2 py-1.5 border-b">
- <input
- type="text"
- value={query}
- onChange={(e) => {
- setQuery(e.target.value);
- pendingSearchHighlight.current = true;
- onSearchChange?.(e.target.value);
- }}
- onKeyDown={handleKeyDown}
- placeholder={placeholder}
- aria-label={filterAria}
- className="w-full bg-transparent text-body placeholder:text-muted-foreground outline-none"
- />
- </div>
- )}
- {header && <div className="border-b">{header}</div>}
- <div ref={listRef} className="p-1 max-h-72 overflow-y-auto">{children}</div>
- {footer && <div className="border-t p-1">{footer}</div>}
- </PopoverContent>
- </Popover>
+ {header && <div className="border-b">{header}</div>}
+ <div ref={listRef} className="p-1 max-h-72 overflow-y-auto">{children}</div>
+ {footer && <div className="border-t p-1">{footer}</div>}
+ </>
);
}