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): let touch start drags on board cards

Tin81ba0a3284e5
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 9eb7e32cc..dffa0797f 100644
--- a/apps/web/src/components/kanban-board/task-card.test.tsx
+++ b/apps/web/src/components/kanban-board/task-card.test.tsx
@@ -1,14 +1,16 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { cleanup, render, screen } from "@testing-library/react";
+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 Task from "@/types/task";
import TaskCard from "./task-card";
+const onTouchStart = vi.hoisted(() => vi.fn());
+
vi.mock("@dnd-kit/sortable", () => ({
useSortable: () => ({
attributes: {},
- listeners: {},
+ listeners: { onTouchStart },
setNodeRef: vi.fn(),
transform: null,
}),
@@ -73,24 +75,33 @@ const wrapper = ({ children }: { children: ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
+const task: Task = {
+ id: "task",
+ title: "Open work",
+ status: "shared",
+ projectId: "project",
+ number: 1,
+ description: null,
+ priority: "high",
+ startDate: null,
+ dueDate: "2030-01-01T00:00:00Z",
+ position: 1,
+ createdAt: "2026-10-01T00:00:00Z",
+ userId: null,
+ assigneeId: null,
+ assigneeName: null,
+ labels: [{ id: "label", name: "Regression label", color: "red" }],
+};
+
+it("passes touches inside the context menu trigger to the touch sensor", () => {
+ render(<TaskCard task={task} />, { wrapper });
+ fireEvent.touchStart(screen.getByText("Open work"), {
+ touches: [{ clientX: 0, clientY: 0 }],
+ });
+ expect(onTouchStart).toHaveBeenCalledOnce();
+});
+
it("keeps details in the rendered open column despite a final column sharing its slug", () => {
- const task: Task = {
- id: "task",
- title: "Open work",
- status: "shared",
- projectId: "project",
- number: 1,
- description: null,
- priority: "high",
- startDate: null,
- dueDate: "2030-01-01T00:00:00Z",
- position: 1,
- createdAt: "2026-10-01T00:00:00Z",
- userId: null,
- assigneeId: null,
- assigneeName: null,
- labels: [{ id: "label", name: "Regression label", color: "red" }],
- };
const view = render(<TaskCard task={task} isFinalColumn={false} />, {
wrapper,
});
diff --git a/apps/web/src/components/kanban-board/task-card/index.tsx b/apps/web/src/components/kanban-board/task-card/index.tsx
index a2bbe1ed9..158016150 100644
--- a/apps/web/src/components/kanban-board/task-card/index.tsx
+++ b/apps/web/src/components/kanban-board/task-card/index.tsx
@@ -34,6 +34,9 @@ function TaskCard({
data: { isFinalColumn },
transition: { duration: 200, easing: EASE_OUT_CSS },
});
+ // The context menu trigger inside the card stops touchstart from bubbling,
+ // so the TouchSensor has to receive it in the capture phase.
+ const { onTouchStart, ...dragListeners } = listeners ?? {};
const { handleKeyDown } = useTaskCardClick(task);
const hoverPrefetch = useTaskHoverPrefetch(task.id);
const setFocusedTask = useBulkSelectionStore((state) => state.setFocusedTask);
@@ -55,7 +58,8 @@ function TaskCard({
data-task-id={task.id}
data-shortcut-surface
{...attributes}
- {...listeners}
+ {...dragListeners}
+ onTouchStartCapture={(event) => onTouchStart?.(event)}
{...hoverPrefetch}
role="button"
tabIndex={0}