Skip to content

Commit 45bd1e8

Browse files
authored
feat(starter): in start block input format, don't prevent deletion if only one field remaining, just clear form (#2830)
1 parent 85d6e3e commit 45bd1e8

File tree

1 file changed

+9
-3
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/starter

1 file changed

+9
-3
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/starter/input-format.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,16 @@ export function FieldFormat({
125125
}
126126

127127
/**
128-
* Removes a field by ID, preventing removal of the last field
128+
* Removes a field by ID, or clears it if it's the last field
129129
*/
130130
const removeField = (id: string) => {
131-
if (isReadOnly || fields.length === 1) return
131+
if (isReadOnly) return
132+
133+
if (fields.length === 1) {
134+
setStoreValue([createDefaultField()])
135+
return
136+
}
137+
132138
setStoreValue(fields.filter((field) => field.id !== id))
133139
}
134140

@@ -273,7 +279,7 @@ export function FieldFormat({
273279
<Button
274280
variant='ghost'
275281
onClick={() => removeField(field.id)}
276-
disabled={isReadOnly || fields.length === 1}
282+
disabled={isReadOnly}
277283
className='h-auto p-0 text-[var(--text-error)] hover:text-[var(--text-error)]'
278284
>
279285
<Trash className='h-[14px] w-[14px]' />

0 commit comments

Comments
 (0)