From ba08a2fd347b670cfb5231173e57f9d88f9a47d3 Mon Sep 17 00:00:00 2001 From: bboysoul Date: Tue, 8 Sep 2026 17:43:56 +0800 Subject: [PATCH] fix: collapse subtasks when opening lists --- frontend/src/App.vue | 13 +++++++++++-- frontend/src/style.test.ts | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 49d0e16..3da134a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -324,7 +324,10 @@ function restoreNavigation(inboxId: string) { async function loadRestoredView() { if (activeView.value === 'trash') await loadTrash() - else if (isTaskView(activeView.value)) await loadAll() + else if (isTaskView(activeView.value)) { + await loadAll() + if (activeView.value === 'tasks') collapseLoadedTaskChildren() + } else { tasks.value = []; totalTasks.value = 0 } } @@ -479,7 +482,10 @@ async function switchView(view: View, listId?: string) { if (view === 'trash') await loadTrash() else if (view === 'today') await loadTodayView() else if (!isTaskView(view)) tasks.value = [] - else await loadAll() + else { + await loadAll() + if (view === 'tasks') collapseLoadedTaskChildren() + } } async function loadTodayView() { await loadAll() @@ -646,6 +652,9 @@ function cancelTaskSwipe(task?: Task) { taskSwipeStart.value = null if (task) taskSwipeOffsets.value[task.id] = 0 } +function collapseLoadedTaskChildren() { + collapsedTaskIds.value = new Set(tasks.value.filter((task) => task.subtasks?.length).map((task) => task.id)) +} function toggleTaskChildren(task: Task) { if (!task.subtasks?.length) return const next = new Set(collapsedTaskIds.value) diff --git a/frontend/src/style.test.ts b/frontend/src/style.test.ts index 7dcd733..59b36d7 100644 --- a/frontend/src/style.test.ts +++ b/frontend/src/style.test.ts @@ -90,6 +90,13 @@ describe('task and habit row decoration', () => { expect(app).toContain(':aria-expanded="!collapsedTaskIds.has(node.task.id)"') }) + it('starts parent tasks collapsed when entering a task list', () => { + expect(app).toContain('function collapseLoadedTaskChildren()') + expect(app).toContain("else if (isTaskView(activeView.value)) {\n await loadAll()\n if (activeView.value === 'tasks') collapseLoadedTaskChildren()") + expect(app).toContain("else {\n await loadAll()\n if (view === 'tasks') collapseLoadedTaskChildren()") + expect(app).toContain('tasks.value.filter((task) => task.subtasks?.length).map((task) => task.id)') + }) + it('shows visible completion buttons for tasks and subtasks while keeping swipe shortcuts', () => { expect(app).not.toContain('class="sr-only" :aria-label="node.task.completed') expect(app).not.toContain('class="sr-only" :aria-label="subtask.completed')