fix: collapse subtasks when opening lists
This commit is contained in:
+11
-2
@@ -324,7 +324,10 @@ function restoreNavigation(inboxId: string) {
|
|||||||
|
|
||||||
async function loadRestoredView() {
|
async function loadRestoredView() {
|
||||||
if (activeView.value === 'trash') await loadTrash()
|
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 }
|
else { tasks.value = []; totalTasks.value = 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +482,10 @@ async function switchView(view: View, listId?: string) {
|
|||||||
if (view === 'trash') await loadTrash()
|
if (view === 'trash') await loadTrash()
|
||||||
else if (view === 'today') await loadTodayView()
|
else if (view === 'today') await loadTodayView()
|
||||||
else if (!isTaskView(view)) tasks.value = []
|
else if (!isTaskView(view)) tasks.value = []
|
||||||
else await loadAll()
|
else {
|
||||||
|
await loadAll()
|
||||||
|
if (view === 'tasks') collapseLoadedTaskChildren()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function loadTodayView() {
|
async function loadTodayView() {
|
||||||
await loadAll()
|
await loadAll()
|
||||||
@@ -646,6 +652,9 @@ function cancelTaskSwipe(task?: Task) {
|
|||||||
taskSwipeStart.value = null
|
taskSwipeStart.value = null
|
||||||
if (task) taskSwipeOffsets.value[task.id] = 0
|
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) {
|
function toggleTaskChildren(task: Task) {
|
||||||
if (!task.subtasks?.length) return
|
if (!task.subtasks?.length) return
|
||||||
const next = new Set(collapsedTaskIds.value)
|
const next = new Set(collapsedTaskIds.value)
|
||||||
|
|||||||
@@ -90,6 +90,13 @@ describe('task and habit row decoration', () => {
|
|||||||
expect(app).toContain(':aria-expanded="!collapsedTaskIds.has(node.task.id)"')
|
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', () => {
|
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="node.task.completed')
|
||||||
expect(app).not.toContain('class="sr-only" :aria-label="subtask.completed')
|
expect(app).not.toContain('class="sr-only" :aria-label="subtask.completed')
|
||||||
|
|||||||
Reference in New Issue
Block a user