Skip to content

Commit 02b8fcd

Browse files
fix(custom-block): derive fields for disabled blocks so edits keep placeholders; reseed edit form after async load
1 parent 5b73abb commit 02b8fcd

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

apps/sim/ee/custom-blocks/components/custom-block-detail.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ export function CustomBlockDetail({ blockId, workspaceId, onBack }: CustomBlockD
9999
const [error, setError] = useState<string | null>(null)
100100
const [showDelete, setShowDelete] = useState(false)
101101

102+
// Edit mode may mount before `useCustomBlocks` has resolved this row, leaving the
103+
// buffers empty. Reseed them the first time the block's identity loads (or when it
104+
// changes) — keyed on `existing.id` so a later refetch of the SAME block doesn't
105+
// clobber in-progress edits. (The icon reseeds itself via `currentImage`.)
106+
const [seededId, setSeededId] = useState(existing?.id ?? null)
107+
if (existing && existing.id !== seededId) {
108+
setSeededId(existing.id)
109+
setName(existing.name)
110+
setDescription(existing.description ?? '')
111+
setInputs(toCustomBlockInputs(existing.inputFields))
112+
setOutputs(existing.exposedOutputs ?? [])
113+
}
114+
102115
const iconUpload = useProfilePictureUpload({
103116
currentImage: existing?.iconUrl ?? null,
104117
onError: (e) => setError(e),

apps/sim/lib/workflows/custom-blocks/operations.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ export async function listCustomBlocksWithInputs(
180180
description: row.description,
181181
iconUrl: row.iconUrl,
182182
enabled: row.enabled,
183-
// Field set derived live from the deployed Start; stored placeholders merged in.
184-
inputFields: applyInputPlaceholders(
185-
row.inputs,
186-
row.enabled ? await deriveInputFields(row.workflowId) : []
187-
),
183+
// Field set derived live from the deployed Start; stored placeholders merged
184+
// in. Derive even for a disabled block — the source workflow's deployment is
185+
// independent of the block's enabled flag, and the edit form needs the real
186+
// fields so a save doesn't overwrite the block's stored placeholders.
187+
inputFields: applyInputPlaceholders(row.inputs, await deriveInputFields(row.workflowId)),
188188
exposedOutputs: row.outputs ?? [],
189189
}))
190190
)

0 commit comments

Comments
 (0)