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): align rows with and without a subtask toggle

Juan2561cddbee90
diff --git a/apps/web/src/components/list-view/index.tsx b/apps/web/src/components/list-view/index.tsx
index 90f7bec3f..1847dbe90 100644
--- a/apps/web/src/components/list-view/index.tsx
+++ b/apps/web/src/components/list-view/index.tsx
@@ -351,6 +351,9 @@ function ListView({ project, disableDragDrop = false }: ListViewProps) {
// A dragged parent collapses for the duration: moving a row while its
// children are rendered beneath it has no single correct outcome, and
// hiding them keeps the drag to the one row the user grabbed.
+ // Reserving the toggle column on every row keeps the titles aligned, but
+ // only where the group actually has subtasks; a project without any keeps
+ // the original left edge.
const rows = flattenSubtaskRows({
tasks: column.tasks,
children: subtaskChildren,
@@ -365,6 +368,10 @@ function ListView({ project, disableDragDrop = false }: ListViewProps) {
},
});
+ const groupHasSubtasks = rows.some(
+ (row) => row.childCount > 0 || row.depth > 0,
+ );
+
return (
<div
className={cn(
@@ -444,6 +451,7 @@ function ListView({ project, disableDragDrop = false }: ListViewProps) {
<TaskRow
task={row.task}
projectSlug={project?.slug ?? ""}
+ reserveToggleSpace={groupHasSubtasks}
depth={row.depth}
rowId={row.rowId}
childCount={row.childCount}
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 3807ace1b..991bae5fd 100644
--- a/apps/web/src/components/list-view/task-row.test.tsx
+++ b/apps/web/src/components/list-view/task-row.test.tsx
@@ -140,6 +140,39 @@ describe("TaskRow", () => {
expect(toggle.closest('[role="button"]')).toBeNull();
});
+ it("reserves the toggle column so titles stay aligned in a group", () => {
+ const { container: withToggle } = render(
+ <TaskRow
+ task={task}
+ projectSlug="kan"
+ childCount={1}
+ reserveToggleSpace
+ onToggleExpanded={vi.fn()}
+ />,
+ );
+ const { container: withoutToggle } = render(
+ <TaskRow task={task} projectSlug="kan" reserveToggleSpace />,
+ );
+
+ const gutter = (root: HTMLElement) =>
+ root.firstElementChild?.firstElementChild;
+
+ // A row with no children still renders the column, so its number and title
+ // start at the same offset as a sibling that does have one.
+ expect(gutter(withToggle)).not.toBeNull();
+ expect(gutter(withoutToggle)).not.toBeNull();
+ expect(gutter(withoutToggle)?.className).toEqual(
+ gutter(withToggle)?.className,
+ );
+ });
+
+ it("keeps the original left edge when a group has no subtasks", () => {
+ const { container } = render(<TaskRow task={task} projectSlug="kan" />);
+ const draggable = container.querySelector('[role="button"]');
+
+ expect(draggable?.className).toContain("pl-4");
+ });
+
it("labels the toggle by its resulting state", () => {
render(
<TaskRow
diff --git a/apps/web/src/components/list-view/task-row.tsx b/apps/web/src/components/list-view/task-row.tsx
index 304463724..56b0a2007 100644
--- a/apps/web/src/components/list-view/task-row.tsx
+++ b/apps/web/src/components/list-view/task-row.tsx
@@ -62,6 +62,11 @@ type TaskRowProps = {
childCount?: number;
isExpanded?: boolean;
onToggleExpanded?: () => void;
+ /**
+ * Keeps the toggle column present on rows that have no toggle, so titles in
+ * a group containing subtasks stay on one vertical line.
+ */
+ reserveToggleSpace?: boolean;
};
function TaskRow({
@@ -72,7 +77,9 @@ function TaskRow({
childCount = 0,
isExpanded = false,
onToggleExpanded,
+ reserveToggleSpace = false,
}: TaskRowProps) {
+ const showToggleColumn = depth > 0 || childCount > 0 || reserveToggleSpace;
const { t } = useTranslation();
const navigate = useNavigate();
// Only the top-level row is a drag source. A nested repeat shares its task
@@ -211,7 +218,7 @@ function TaskRow({
isTaskFocused && "ring-2 ring-inset ring-ring/50",
)}
>
- {(depth > 0 || childCount > 0) && (
+ {showToggleColumn && (
<div
className={cn(
"flex flex-shrink-0 items-center pl-4",
@@ -261,7 +268,7 @@ function TaskRow({
onKeyDown={handleKeyDown}
className={cn(
"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",
+ showToggleColumn ? "pl-2" : "pl-4",
isTaskSelected ? "bg-accent/45" : "group-hover:bg-accent/60",
)}
{...attributes}