From 3a7051e4eed82528298d90d591f353a4cf546b1e Mon Sep 17 00:00:00 2001 From: shrimbly Date: Fri, 27 Feb 2026 23:54:12 +1300 Subject: [PATCH] fix: prevent SwitchNode from deleting last switch Add guard in handleDelete and hide the delete button when only one switch remains, matching ConditionalSwitchNode's existing behavior. Co-Authored-By: Claude Opus 4.6 --- src/components/nodes/SwitchNode.tsx | 41 ++++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/components/nodes/SwitchNode.tsx b/src/components/nodes/SwitchNode.tsx index b171bd8d..01497c36 100644 --- a/src/components/nodes/SwitchNode.tsx +++ b/src/components/nodes/SwitchNode.tsx @@ -92,6 +92,7 @@ export const SwitchNode = memo(({ id, data, selected }: NodeProps) // Handle delete switch const handleDelete = useCallback( (switchId: string) => { + if (nodeData.switches.length <= 1) return; const updatedSwitches = nodeData.switches.filter((sw) => sw.id !== switchId); updateNodeData(id, { switches: updatedSwitches }); @@ -227,26 +228,28 @@ export const SwitchNode = memo(({ id, data, selected }: NodeProps) )} - {/* Delete button */} - + + + + + )} ))}