Skip to content

fix(web): default new work item to the first project in sidebar order - #9593

Open
gaerae wants to merge 1 commit into
makeplane:previewfrom
gaerae:fix/work-item-modal-default-project
Open

fix(web): default new work item to the first project in sidebar order#9593
gaerae wants to merge 1 commit into
makeplane:previewfrom
gaerae:fix/work-item-modal-default-project

Conversation

@gaerae

@gaerae gaerae commented Aug 12, 2026

Copy link
Copy Markdown

Description

The New work item modal preselects allowedProjectIds[0], and the issue modal provider builds that list with Object.keys(projectsWithCreatePermissions). That map is the response of GET /api/users/me/workspaces/<slug>/project-roles/, whose key order is the ProjectMember default ordering ("-created_at",) — the order the user joined the projects, newest first.

Everything the user sees is ordered by sort_order instead: the sidebar and the modal's own ProjectDropdown both read joinedProjectIds from the project store. The two orders match on a fresh workspace and drift apart as soon as projects are dragged into a different order, since dragging writes ProjectUserProperty.sort_order and leaves ProjectMember.created_at untouched. The preselected project then has no relation to the list the user is looking at.

The permission map is also not filtered by archived_at, so an archived project can end up as allowedProjectIds[0]. It is absent from the dropdown (that list excludes archived projects), so the modal preselects a project the user cannot see or pick, and saving fails with a 500 from the work item create endpoint.

This derives the fallback list from joinedProjectIds and keeps only the projects the user can create in. The list stays in the order the user sees, archived projects drop out, and everything else about the modal is unchanged — a project id from the route still wins over the fallback, and an explicit allowedProjectIds prop is still passed straight through.

Fixes #9592

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Six projects, with the sidebar dragged into the order Alpha, Bravo, Echo, Delta, Charlie, Foxtrot.

Before — the modal preselects Foxtrot, the last project in the sidebar:

Create new work item modal preselecting Foxtrot while the sidebar starts with Alpha

After — the modal preselects Alpha, the first project in the sidebar:

Create new work item modal preselecting Alpha, matching the top of the sidebar

Archived-project variant, before the changeFoxtrot is archived, so it is gone from the sidebar and from the modal's project dropdown, yet the modal still preselects it and Save returns a 500:

Create new work item modal preselecting the archived Foxtrot project, which is absent from the sidebar

Test Scenarios

Verified against a self-hosted v1.4.1 stack (makeplane/plane-backend:v1.4.1 and friends) with the web app running from source, in a workspace with six projects that were dragged out of their default order:

  • Home → New work item preselects Alpha, the first project in the sidebar, instead of Foxtrot. The dropdown order and contents are unchanged.
  • With Foxtrot archived: before the change the modal preselected it and Save returned 500; after the change the modal preselects Alpha and the work item is created.
  • Unarchiving Foxtrot puts it back at the bottom of the sidebar, and the default stays Alpha.
  • Opening the modal from inside a project (/<workspace>/projects/<id>/issues/) still preselects that project — the route still takes precedence over the fallback.
  • pnpm --filter web check:types, oxlint and oxfmt --check pass on the changed file.

No unit tests are included: apps/web has no test runner configured, so there is nowhere to hang a spec for this yet.

References

Fixes #9592

Summary by CodeRabbit

  • Bug Fixes
    • Project selection now respects sidebar order.
    • Archived projects are excluded from project creation options.
    • Only projects where you have create permissions are shown.

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.
@CLAassistant

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f26de7f-1310-4d37-bc86-3243d12c7195

📥 Commits

Reviewing files that changed from the base of the PR and between 1c8a60f and fd5bb91.

📒 Files selected for processing (1)
  • apps/web/core/components/issues/issue-modal/provider.tsx

📝 Walkthrough

Walkthrough

The issue modal provider now derives create-permitted project IDs from ordered, non-archived project memberships instead of permission-map keys.

Changes

Issue modal project selection

Layer / File(s) Summary
Filter projects by visible order
apps/web/core/components/issues/issue-modal/provider.tsx
The provider uses useProject and filters joinedProjectIds by create permissions. The resulting project IDs preserve sidebar order and exclude archived projects.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: sriramveeraghanta

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change satisfies issue [#9592] by using sidebar order, filtering archived projects, preserving route precedence, and retaining explicit project IDs.
Out of Scope Changes check ✅ Passed The single-file change is limited to the linked issue and PR objectives, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the main fix: defaulting new work items to the first project in sidebar order.
Description check ✅ Passed The description covers the issue, implementation, behavior changes, test scenarios, screenshots, change type, and issue reference.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: "New work item" preselects a project that does not match the sidebar order, and can preselect an archived project

2 participants