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): unnest the subtask toggle and refresh relations on move

Juan35b86efa085d
diff --git a/apps/web/src/components/list-view/task-row.test.tsx b/apps/web/src/components/list-view/task-row.test.tsx
index 2e266c6cd..3807ace1b 100644
--- a/apps/web/src/components/list-view/task-row.test.tsx
+++ b/apps/web/src/components/list-view/task-row.test.tsx
@@ -108,4 +108,50 @@ describe("TaskRow", () => {
expect(useExternalLinks).not.toHaveBeenCalled();
expect(useGetLabelsByTask).not.toHaveBeenCalled();
});
+
+ it("shows no subtask toggle when the task has no children", () => {
+ render(<TaskRow task={task} projectSlug="kan" />);
+
+ expect(
+ screen.queryByLabelText("tasks:listView.expandSubtasks"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("keeps the subtask toggle outside the drag activator", () => {
+ render(
+ <TaskRow
+ task={task}
+ projectSlug="kan"
+ rowId="parent/task-1"
+ depth={1}
+ childCount={2}
+ onToggleExpanded={vi.fn()}
+ />,
+ );
+
+ const toggle = screen.getByLabelText("tasks:listView.expandSubtasks");
+ const activator = document.querySelector('[role="button"]');
+
+ // dnd-kit gives its activator role="button". A button nested inside one is
+ // an ambiguous control for assistive technology, so the toggle has to be a
+ // sibling of the draggable region rather than a descendant.
+ expect(activator).not.toBeNull();
+ expect(activator?.contains(toggle)).toBe(false);
+ expect(toggle.closest('[role="button"]')).toBeNull();
+ });
+
+ it("labels the toggle by its resulting state", () => {
+ render(
+ <TaskRow
+ task={task}
+ projectSlug="kan"
+ childCount={1}
+ isExpanded
+ onToggleExpanded={vi.fn()}
+ />,
+ );
+
+ const toggle = screen.getByLabelText("tasks:listView.collapseSubtasks");
+ expect(toggle).toHaveAttribute("aria-expanded", "true");
+ });
});
diff --git a/apps/web/src/components/list-view/task-row.tsx b/apps/web/src/components/list-view/task-row.tsx
index f338a0b80..304463724 100644
--- a/apps/web/src/components/list-view/task-row.tsx
+++ b/apps/web/src/components/list-view/task-row.tsx
@@ -201,13 +201,58 @@ function TaskRow({
ref={setNodeRef}
style={style}
className={cn(
- "border-b border-border/50 transition-colors duration-150",
+ // The indent and the toggle sit beside the draggable region rather
+ // than inside it: dnd-kit gives its activator role="button", and a
+ // button nested in one is an ambiguous control for assistive tech.
+ "group flex items-stretch border-b border-border/50 transition-colors duration-150",
isDragging && "opacity-50",
isTaskSelected &&
"bg-accent/60 shadow-sm ring-1 ring-inset ring-ring/30",
isTaskFocused && "ring-2 ring-inset ring-ring/50",
)}
>
+ {(depth > 0 || childCount > 0) && (
+ <div
+ className={cn(
+ "flex flex-shrink-0 items-center pl-4",
+ isTaskSelected ? "bg-accent/45" : "group-hover:bg-accent/60",
+ )}
+ >
+ {depth > 0 && (
+ <span
+ aria-hidden="true"
+ className="flex-shrink-0"
+ // Indentation is capped so a deep chain cannot push the title
+ // off the row; the chevrons still convey the nesting.
+ style={{ width: `${Math.min(depth, 6) * 1.25}rem` }}
+ />
+ )}
+
+ {childCount > 0 ? (
+ <button
+ type="button"
+ onClick={onToggleExpanded}
+ aria-expanded={isExpanded}
+ aria-label={
+ isExpanded
+ ? t("tasks:listView.collapseSubtasks")
+ : t("tasks:listView.expandSubtasks")
+ }
+ className="flex-shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
+ >
+ <ChevronRight
+ className={cn(
+ "w-3 h-3 transition-transform",
+ isExpanded && "rotate-90",
+ )}
+ />
+ </button>
+ ) : (
+ <span aria-hidden="true" className="w-5 flex-shrink-0" />
+ )}
+ </div>
+ )}
+
<ContextMenu>
<ContextMenuTrigger asChild>
{/* biome-ignore lint/a11y/noStaticElementInteractions: false positive for onClick and onKeyDown */}
@@ -215,53 +260,13 @@ function TaskRow({
onClick={handleClick}
onKeyDown={handleKeyDown}
className={cn(
- "group relative flex items-center gap-3 px-4 py-1.5 transition-colors cursor-pointer",
- isTaskSelected ? "bg-accent/45" : "hover:bg-accent/60",
+ "relative flex min-w-0 flex-1 items-center gap-3 py-1.5 pr-4 transition-colors cursor-pointer",
+ depth > 0 || childCount > 0 ? "pl-2" : "pl-4",
+ isTaskSelected ? "bg-accent/45" : "group-hover:bg-accent/60",
)}
{...attributes}
{...listeners}
>
- {depth > 0 && (
- <div
- aria-hidden="true"
- className="flex-shrink-0"
- // Indentation is capped so a deep chain cannot push the title
- // off the row; the chevrons still convey the nesting.
- style={{ width: `${Math.min(depth, 6) * 1.25}rem` }}
- />
- )}
-
- {childCount > 0 ? (
- <button
- type="button"
- onClick={(e) => {
- e.stopPropagation();
- onToggleExpanded?.();
- }}
- // The row handles Enter by opening the task, and a button's
- // Enter keydown bubbles there even though its click does not.
- onKeyDown={(e) => e.stopPropagation()}
- aria-expanded={isExpanded}
- aria-label={
- isExpanded
- ? t("tasks:listView.collapseSubtasks")
- : t("tasks:listView.expandSubtasks")
- }
- className="flex-shrink-0 -my-1 -mx-1 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
- >
- <ChevronRight
- className={cn(
- "w-3 h-3 transition-transform",
- isExpanded && "rotate-90",
- )}
- />
- </button>
- ) : (
- depth > 0 && (
- <div aria-hidden="true" className="w-3 flex-shrink-0" />
- )
- )}
-
{showPriority && (
<div className="flex-shrink-0 first:[&_svg]:h-4 first:[&_svg]:w-4">
{getPriorityIcon(task.priority ?? "")}
diff --git a/apps/web/src/hooks/mutations/task/use-move-task.ts b/apps/web/src/hooks/mutations/task/use-move-task.ts
index ac1055ccb..f1d1c09c6 100644
--- a/apps/web/src/hooks/mutations/task/use-move-task.ts
+++ b/apps/web/src/hooks/mutations/task/use-move-task.ts
@@ -20,6 +20,16 @@ export function useMoveTask() {
queryClient.invalidateQueries({
queryKey: ["tasks", result.destinationProjectId],
});
+ // The list view reads relations per project, and moving a task changes
+ // which edges are internal to each side. The websocket broadcast skips
+ // the window that started the move, so this is the only path that
+ // refreshes it for whoever performed it.
+ queryClient.invalidateQueries({
+ queryKey: ["task-relations", "project", result.sourceProjectId],
+ });
+ queryClient.invalidateQueries({
+ queryKey: ["task-relations", "project", result.destinationProjectId],
+ });
queryClient.invalidateQueries({
queryKey: ["projects"],
});