diff --git a/frontend/src/components/procedural-editor/StepList.tsx b/frontend/src/components/procedural-editor/StepList.tsx index 066843b0..f413fb48 100644 --- a/frontend/src/components/procedural-editor/StepList.tsx +++ b/frontend/src/components/procedural-editor/StepList.tsx @@ -1,3 +1,4 @@ +import { useRef, useEffect } from 'react' import { Plus, GripVertical, Trash2, ChevronDown, CheckCircle2, AlertTriangle, Info, Zap, Shield, SeparatorHorizontal } from 'lucide-react' import type { StepContentType } from '@/types' import { StepEditor } from './StepEditor' @@ -24,16 +25,35 @@ export function StepList() { } = useProceduralEditorStore() const procedureSteps = steps.filter((s) => s.type === 'procedure_step') + const totalMinutes = steps + .filter(s => s.type === 'procedure_step' && s.estimated_minutes) + .reduce((sum, s) => sum + (s.estimated_minutes || 0), 0) + + // Auto-scroll to new steps + const scrollTargetRef = useRef(null) + const prevStepCount = useRef(steps.length) + + useEffect(() => { + if (steps.length > prevStepCount.current) { + // Scroll the newly expanded step into view + setTimeout(() => { + scrollTargetRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }) + }, 50) + } + prevStepCount.current = steps.length + }, [steps.length]) + let stepCounter = 0 return ( -
+

Steps

- ({procedureSteps.length} step{procedureSteps.length !== 1 ? 's' : ''}) + ({procedureSteps.length} step{procedureSteps.length !== 1 ? 's' : ''} + {totalMinutes > 0 ? ` \u00b7 ~${totalMinutes} min` : ''})
@@ -81,7 +101,7 @@ export function StepList() { if (isExpanded) { return ( -
+
+
Add Step + +
) }