Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(projects): show reorder handle on touch and cover archived ordering

Rojenson Lugo2b1f92f26879
diff --git a/apps/web/src/components/nav-projects.tsx b/apps/web/src/components/nav-projects.tsx
index c5cc2c5f9..60f3b0f18 100644
--- a/apps/web/src/components/nav-projects.tsx
+++ b/apps/web/src/components/nav-projects.tsx
@@ -101,10 +101,12 @@ function SortableProjectItem({
// Only the handle activates a drag. Spreading the sortable props over
// the whole item would make it a role="button" tab stop wrapping the
// menu and dropdown buttons, and would let Enter start a drag.
+ // The handle stays visible below `md`: `TouchSensor` is registered, and
+ // touch devices never hover, so hiding it there strands the affordance.
<button
type="button"
ref={setActivatorNodeRef}
- className="absolute top-1.5 end-6 z-10 flex aspect-square w-5 cursor-grab items-center justify-center rounded-lg p-0 text-sidebar-foreground opacity-0 outline-hidden ring-sidebar-ring transition-opacity hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:opacity-100 focus-visible:ring-2 group-data-[collapsible=icon]:hidden group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100"
+ className="absolute top-1.5 end-6 z-10 flex aspect-square w-5 cursor-grab items-center justify-center rounded-lg p-0 text-sidebar-foreground opacity-100 outline-hidden md:opacity-0 ring-sidebar-ring transition-opacity hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:opacity-100 focus-visible:ring-2 group-data-[collapsible=icon]:hidden group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100"
onClick={(event) => event.stopPropagation()}
{...attributes}
{...listeners}
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
index 5f3b3bccd..2148c0ca8 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
@@ -96,11 +96,13 @@ function SortableProjectRow({
<TableCell className="w-8 py-3 pe-0">
{canReorder && (
// The row itself navigates on click, so only the handle activates a
- // drag.
+ // drag. It stays visible below `md`: `TouchSensor` is registered, and
+ // touch devices never hover, so hiding it there strands the
+ // affordance.
<button
type="button"
ref={setActivatorNodeRef}
- className="flex cursor-grab items-center text-muted-foreground opacity-0 transition-opacity focus-visible:opacity-100 group-hover/row:opacity-100 hover:text-foreground"
+ className="flex cursor-grab items-center text-muted-foreground opacity-100 transition-opacity md:opacity-0 focus-visible:opacity-100 group-hover/row:opacity-100 hover:text-foreground"
onClick={(event) => event.stopPropagation()}
{...attributes}
{...listeners}
diff --git a/tests/api-integration/project-reorder.test.ts b/tests/api-integration/project-reorder.test.ts
index 3db1e3a8f..b7e4471d7 100644
--- a/tests/api-integration/project-reorder.test.ts
+++ b/tests/api-integration/project-reorder.test.ts
@@ -10,12 +10,21 @@ import {
type ProjectListEntry = typeof schema.projectTable.$inferSelect;
-async function listProjects(workspaceId: string) {
+async function listProjects(workspaceId: string, includeArchived = false) {
const { app } = createApp();
- const response = await app.request(`/api/project?workspaceId=${workspaceId}`);
+ const response = await app.request(
+ `/api/project?workspaceId=${workspaceId}${
+ includeArchived ? "&includeArchived=true" : ""
+ }`,
+ );
return (await response.json()) as ProjectListEntry[];
}
+function archiveRequest(projectId: string) {
+ const { app } = createApp();
+ return app.request(`/api/project/${projectId}/archive`, { method: "PUT" });
+}
+
function reorderRequest(
workspaceId: string,
projects: Array<{ id: string; position: number }>,
@@ -216,6 +225,49 @@ describe("API integration: project reorder", () => {
expect(projects.map((project) => project.position)).toEqual([0, 1, 2]);
});
+ it("keeps an archived project's slot in the ordering", async () => {
+ const member = await createWorkspaceMember({ role: "admin" });
+ const { project: first } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ name: "First",
+ });
+ const { project: second } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ name: "Second",
+ });
+ const { project: archived } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ name: "Archived",
+ });
+
+ mockAuthenticatedSession(member.user);
+
+ expect((await archiveRequest(archived.id)).status).toBe(200);
+
+ // The client never sees the archived project, so it cannot send it. The
+ // controller has to keep it in the workspace ordering anyway.
+ const response = await reorderRequest(member.workspace.id, [
+ { id: second.id, position: 0 },
+ { id: first.id, position: 1 },
+ ]);
+
+ expect(response.status).toBe(200);
+
+ const visibleProjects = await listProjects(member.workspace.id);
+ expect(visibleProjects.map((project) => project.id)).toEqual([
+ second.id,
+ first.id,
+ ]);
+
+ const allProjects = await listProjects(member.workspace.id, true);
+ expect(allProjects.map((project) => project.id)).toEqual([
+ second.id,
+ first.id,
+ archived.id,
+ ]);
+ expect(allProjects.map((project) => project.position)).toEqual([0, 1, 2]);
+ });
+
it("rejects an empty payload", async () => {
const member = await createWorkspaceMember({ role: "admin" });
await createProjectFixture({ workspaceId: member.workspace.id });