From fd5bb919350852ccc2364eac8d7f5880392a9ed5 Mon Sep 17 00:00:00 2001 From: gaerae Date: Wed, 12 Aug 2026 20:43:36 +0900 Subject: [PATCH] fix(web): default new work item to the first project in sidebar order The create work item modal falls back to `allowedProjectIds[0]`, which the issue modal provider builds with `Object.keys(projectsWithCreatePermissions)`. That map is keyed in the order the `project-roles` endpoint returns rows, i.e. by `ProjectMember.created_at` descending, so the preselected project has no relation to the order projects are listed in the sidebar and in the modal's own project dropdown. It also includes archived projects, so the modal can preselect a project that is not in the dropdown at all, and saving then fails with a 500 from the work item create endpoint. Derive the fallback list from `joinedProjectIds` instead, which is sorted by `sort_order` and excludes archived projects, so the default project is the first project the user sees. --- .../core/components/issues/issue-modal/provider.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/web/core/components/issues/issue-modal/provider.tsx b/apps/web/core/components/issues/issue-modal/provider.tsx index a5108234d60..53d80b6dd9f 100644 --- a/apps/web/core/components/issues/issue-modal/provider.tsx +++ b/apps/web/core/components/issues/issue-modal/provider.tsx @@ -11,6 +11,7 @@ import type { ISearchIssueResponse, TIssue } from "@plane/types"; // components import { IssueModalContext } from "@/components/issues/issue-modal/context"; // hooks +import { useProject } from "@/hooks/store/use-project"; import { useUser } from "@/hooks/store/user/user-user"; export type TIssueModalProviderProps = { @@ -26,8 +27,15 @@ export const IssueModalProvider = observer(function IssueModalProvider(props: TI const [selectedParentIssue, setSelectedParentIssue] = useState(null); // store hooks const { projectsWithCreatePermissions } = useUser(); + const { joinedProjectIds } = useProject(); // derived values - const projectIdsWithCreatePermissions = Object.keys(projectsWithCreatePermissions ?? {}); + // `projectsWithCreatePermissions` is keyed by project id in whatever order the + // permission map came back in, so deriving the list from `joinedProjectIds` keeps it in + // the order projects are listed in the sidebar and the project dropdown, and leaves out + // archived projects. + const projectIdsWithCreatePermissions = joinedProjectIds.filter( + (projectId) => !!projectsWithCreatePermissions?.[projectId] + ); return (