feat(starter): in start block input format, don't prevent deletion if only one field remaining, just clear form (#2830)

This commit is contained in:
Waleed
2026-01-14 21:24:02 -08:00
committed by GitHub
parent 85d6e3e3bd
commit 45bd1e8cd7

View File

@@ -125,10 +125,16 @@ export function FieldFormat({
}
/**
* Removes a field by ID, preventing removal of the last field
* Removes a field by ID, or clears it if it's the last field
*/
const removeField = (id: string) => {
if (isReadOnly || fields.length === 1) return
if (isReadOnly) return
if (fields.length === 1) {
setStoreValue([createDefaultField()])
return
}
setStoreValue(fields.filter((field) => field.id !== id))
}
@@ -273,7 +279,7 @@ export function FieldFormat({
<Button
variant='ghost'
onClick={() => removeField(field.id)}
disabled={isReadOnly || fields.length === 1}
disabled={isReadOnly}
className='h-auto p-0 text-[var(--text-error)] hover:text-[var(--text-error)]'
>
<Trash className='h-[14px] w-[14px]' />