From ef52005ddcf2066d87e57f2d88cd3c9c8776f7a6 Mon Sep 17 00:00:00 2001 From: AndreeTorres <00015722@uca.edu.sv> Date: Fri, 24 Jul 2026 23:37:02 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20el=20campo=20de=20subtarea=20vac=C3=ADo?= =?UTF-8?q?=20se=20retira=20solo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El chevron que agregué antes existía pero no resolvía el problema real: nadie espera cerrar un campo huérfano con una flecha de 8 píxeles. Ahora el grupo vacío se colapsa al perder el foco (clic en otra parte) o con Esc, y '+' alterna en vez de solo abrir. Verificado renderizando el estado exacto (grupo expandido sin subtareas) antes y después. --- Corner/UI/NewTaskField.swift | 6 ++++++ Corner/UI/TaskGroupRows.swift | 11 ++++++++++- docs/SPEC.md | 7 ++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Corner/UI/NewTaskField.swift b/Corner/UI/NewTaskField.swift index ae48a59..33ad498 100644 --- a/Corner/UI/NewTaskField.swift +++ b/Corner/UI/NewTaskField.swift @@ -35,6 +35,12 @@ struct NewTaskField: View { focused = false onCancel?() } + .onChange(of: focused) { wasFocused, isFocused in + // Perder el foco con el campo vacío = el usuario se + // arrepintió: avisar para que quien lo muestre lo retire + // (un campo vacío colgando no debe quedarse, SPEC §4.2). + if wasFocused, !isFocused, text.isEmpty { onCancel?() } + } .onAppear { if autofocus { focused = true } } diff --git a/Corner/UI/TaskGroupRows.swift b/Corner/UI/TaskGroupRows.swift index 1ea8dd1..9e80176 100644 --- a/Corner/UI/TaskGroupRows.swift +++ b/Corner/UI/TaskGroupRows.swift @@ -29,7 +29,16 @@ struct TaskGroupRows: View { // si no, tocar "+" y no escribir nada dejaba el campo abierto sin // manera de cerrarlo (SPEC §4.2). onToggleExpand: (subtasks.isEmpty && !isExpanded) ? nil : { toggleExpanded() }, - onAddSubtask: { withAnimation(.snappy) { _ = expanded.insert(task.id) } }, + onAddSubtask: { + withAnimation(.snappy) { + // Segundo toque en un grupo abierto y vacío = cerrarlo. + if isExpanded, subtasks.isEmpty { + expanded.remove(task.id) + } else { + expanded.insert(task.id) + } + } + }, moveDestinations: Self.labeledDestinations(store.moveDestinations(), excluding: task.assignedDay), onMoveToDay: { day in withAnimation(.snappy) { store.move(task, to: day) } }, diff --git a/docs/SPEC.md b/docs/SPEC.md index 1bfcd4f..9fbc492 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -141,9 +141,10 @@ El panel se cierra cuando ocurre cualquiera de: - **UI plegable:** el padre con subtareas muestra un chevron y un contador "2/5". Expandir revela las subtareas indentadas + campo "Agregar paso…". El estado expandido/colapsado es efímero (se colapsa al reabrir el panel). - El chevron también está disponible en un grupo **expandido pero aún vacío**, - y **Esc en su campo lo colapsa**: abrir el campo con "+" y no escribir nada - nunca deja una fila abierta sin forma de cerrarla. + Abrir el campo con "+" y no escribir nada **nunca deja una fila colgada**: + el grupo vacío se colapsa solo al perder el foco (clic en otra parte) o con + `Esc`, "+" vuelve a cerrarlo, y el chevron está disponible en cualquier + grupo expandido aunque no tenga subtareas todavía. - **Crear la primera subtarea:** botón "+" visible al hacer hover sobre la tarea (junto a la ✕), o clic derecho → "Agregar subtarea". Ambos expanden la fila y el campo "Agregar paso…" toma el foco listo para escribir.