Skip to content

Commit a32bbe5

Browse files
committed
fix(workflow): size an unmeasured note as a note
Routing every non-container block through `getBlockMetrics` sent notes through the workflow-card estimate, which counts sub-block rows and an error row a note does not have. A note that had not reported a height yet got a card's box, so a container holding one sized itself around the wrong shape. Give a note its own branch, as the estimate it replaced did: measured height when there is one, and the height an empty note paints when there is not.
1 parent ce31c53 commit a32bbe5

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-node-utilities.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback } from 'react'
22
import { createLogger } from '@sim/logger'
3-
import { BLOCK_DIMENSIONS, CONTAINER_DIMENSIONS } from '@sim/workflow-renderer'
3+
import { BLOCK_DIMENSIONS, CONTAINER_DIMENSIONS, getNoteBlockHeight } from '@sim/workflow-renderer'
44
import { useReactFlow } from 'reactflow'
55
import { getBlockMetrics } from '@/lib/workflows/autolayout/utils'
66
import {
@@ -59,11 +59,17 @@ export function useNodeUtilities(blocks: Record<string, any>) {
5959
}
6060
}
6161

62-
const metrics = getBlockMetrics(block)
63-
return {
64-
width: block.type === 'note' ? BLOCK_DIMENSIONS.NOTE_WIDTH : metrics.width,
65-
height: block.type === 'note' && block.height ? block.height : metrics.height,
62+
/* A note is not a card: it has no sub-block rows and no error row, so the
63+
card estimate does not describe it. Its own height is what it was
64+
measured at, or the height an empty one paints. */
65+
if (block.type === 'note') {
66+
return {
67+
width: BLOCK_DIMENSIONS.NOTE_WIDTH,
68+
height: block.height || getNoteBlockHeight(true),
69+
}
6670
}
71+
72+
return getBlockMetrics(block)
6773
},
6874
[isContainerType]
6975
)

0 commit comments

Comments
 (0)