Skip to content

Commit 59642d1

Browse files
committed
fix(docs): don't expand the inspector template for blocks with no rows
block.rows.every(...) is vacuously true for an empty rows array, so a block defined only by branches (e.g. a router in ROUTING_WORKFLOW) inherited the type template's invented field defaults. Require non-empty authored rows before applying the template.
1 parent 2556fe7 commit 59642d1

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

apps/docs/components/workflow-preview/workflow-preview.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,18 @@ function inspectorFieldsFor(block: PreviewBlock) {
120120
// Show the block type's full field list (from the reference data) with this
121121
// block's example values overlaid, so the inspector reads like the editor's
122122
// panel — every field — not just the summary rows shown on the canvas node.
123-
// Apply the template only when the block's rows are actually a subset of it;
124-
// otherwise the type string is ambiguous (a `table` action vs the table
125-
// trigger, a `webhook` trigger vs the webhook action) and the wrong template
126-
// would win, so the block's own authored rows are the source of truth.
123+
// Apply the template only when the block authored rows that are actually a
124+
// subset of it; otherwise the type string is ambiguous (a `table` action vs
125+
// the table trigger, a `webhook` trigger vs the webhook action) and the wrong
126+
// template would win, so the block's own authored rows are the source of
127+
// truth. A block with no rows (e.g. a router defined only by its branches)
128+
// keeps its empty set rather than inheriting the template's invented defaults.
127129
const exampleByTitle = new Map(block.rows.map((row) => [row.title, row.value]))
128130
const template = BLOCK_DISPLAY_WORKFLOWS[block.type]?.blocks[0]?.rows
129131
const fullRows =
130-
template && block.rows.every((row) => template.some((field) => field.title === row.title))
132+
template &&
133+
block.rows.length > 0 &&
134+
block.rows.every((row) => template.some((field) => field.title === row.title))
131135
? template
132136
: block.rows
133137
const rowFields = fullRows.map((row) => {

0 commit comments

Comments
 (0)