From 8f6cad63651678e5b21c1f2b9aff9c7d7e748f8e Mon Sep 17 00:00:00 2001 From: Tiger Ren Date: Sun, 1 Feb 2026 19:46:47 +0800 Subject: [PATCH] fix: fix add custom step error --- src/components/steps/add-custom-step-dialog.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/steps/add-custom-step-dialog.tsx b/src/components/steps/add-custom-step-dialog.tsx index 29b18d4..3247deb 100644 --- a/src/components/steps/add-custom-step-dialog.tsx +++ b/src/components/steps/add-custom-step-dialog.tsx @@ -60,7 +60,7 @@ export function AddCustomStepDialog({ const [name, setName] = useState(''); const [type, setType] = useState<'bash' | 'sql' | 'text'>('bash'); const [content, setContent] = useState(''); - const [insertAfterId, setInsertAfterId] = useState(''); + const [insertAfterId, setInsertAfterId] = useState('__start__'); const [addToTemplate, setAddToTemplate] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); @@ -76,7 +76,7 @@ export function AddCustomStepDialog({ // Calculate orderIndex based on insert position let orderIndex = existingSteps.length; - if (insertAfterId) { + if (insertAfterId && insertAfterId !== '__start__') { const afterStep = existingSteps.find(s => s.id.toString() === insertAfterId); if (afterStep) { // Use decimal to insert between (e.g., if after step with index 1, use 1.5) @@ -87,7 +87,7 @@ export function AddCustomStepDialog({ orderIndex = afterStep.orderIndex + 1; } } - } else if (existingSteps.length > 0) { + } else if (insertAfterId === '__start__' && existingSteps.length > 0) { // Insert at beginning - use negative decimal or 0.5 before first const firstStep = existingSteps[0]; orderIndex = firstStep.orderIndex / 2; @@ -170,7 +170,7 @@ export function AddCustomStepDialog({ - At the beginning + At the beginning {existingSteps.map((step) => ( After: {step.name}