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(web): keep the hidden custom fields button out of the touch drag

Tin6eb47ae5c8a3
diff --git a/apps/web/src/components/custom-fields/card-field-list.tsx b/apps/web/src/components/custom-fields/card-field-list.tsx
index 8585ad50c..b2f639692 100644
--- a/apps/web/src/components/custom-fields/card-field-list.tsx
+++ b/apps/web/src/components/custom-fields/card-field-list.tsx
@@ -43,6 +43,7 @@ export function CardFieldList({ fields, max, className }: CardFieldListProps) {
})}
onClick={keepCardIdle}
onPointerDown={keepCardIdle}
+ onTouchStart={(event) => event.stopPropagation()}
className={cn(
cardChipClass,
"cursor-default text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
diff --git a/apps/web/src/components/kanban-board/task-card.test.tsx b/apps/web/src/components/kanban-board/task-card.test.tsx
index e42b2eea4..9e7108c76 100644
--- a/apps/web/src/components/kanban-board/task-card.test.tsx
+++ b/apps/web/src/components/kanban-board/task-card.test.tsx
@@ -4,6 +4,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import type { ReactNode } from "react";
import { afterEach, expect, it, vi } from "vite-plus/test";
+import type { CardField } from "@/components/custom-fields/card-fields";
import type Task from "@/types/task";
import TaskCard from "./task-card";
@@ -56,6 +57,10 @@ vi.mock("@/components/task/task-progress-badges", () => ({
vi.mock("@/components/task/task-pull-requests", () => ({
TaskPullRequests: () => null,
}));
+const cardFields = vi.hoisted((): CardField[] => []);
+vi.mock("@/components/custom-fields/use-task-card-fields", () => ({
+ useTaskCardFields: () => cardFields,
+}));
vi.mock("@/hooks/use-workspace-permission", () => ({
// Only the priority picker is editable, so it's the one chip under test.
useWorkspacePermission: () =>
@@ -71,6 +76,7 @@ vi.mock("./task-card-context-menu/task-card-context-menu-content", () => ({
afterEach(() => {
cleanup();
onDragStart.mockClear();
+ cardFields.length = 0;
});
const queryClient = new QueryClient();
@@ -151,6 +157,23 @@ it("doesn't start a drag when a chip is held", async () => {
expect(onDragStart).not.toHaveBeenCalled();
});
+it("doesn't start a drag when the hidden custom fields button is held", async () => {
+ cardFields.push(
+ ...["One", "Two", "Three"].map((name) => ({
+ fieldId: name,
+ name,
+ type: "text" as const,
+ value: name,
+ })),
+ );
+ render(<TaskCard task={task} isFinalColumn={false} />, { wrapper });
+ const more = screen.getByText("+1");
+ fireEvent.touchStart(more, touchAt);
+ await holdPastDelay();
+ fireEvent.touchEnd(more);
+ expect(onDragStart).not.toHaveBeenCalled();
+});
+
it("doesn't start a drag when the portaled picker is held", async () => {
render(<TaskCard task={task} isFinalColumn={false} />, { wrapper });
fireEvent.click(screen.getByTitle(/^tasks:priority.label/));