@@ -18,7 +18,7 @@ import { useShallow } from 'zustand/react/shallow'
1818import type { OAuthConnectEventDetail } from '@/lib/copilot/tools/client/other/oauth-request-access'
1919import { createLogger } from '@/lib/logs/console/logger'
2020import type { OAuthProvider } from '@/lib/oauth'
21- import { BLOCK_DIMENSIONS , CONTAINER_DIMENSIONS } from '@/lib/workflows/blocks/block-dimensions'
21+ import { CONTAINER_DIMENSIONS } from '@/lib/workflows/blocks/block-dimensions'
2222import { TriggerUtils } from '@/lib/workflows/triggers/triggers'
2323import { useWorkspacePermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
2424import {
@@ -177,6 +177,7 @@ const WorkflowContent = React.memo(() => {
177177 resizeLoopNodes,
178178 updateNodeParent : updateNodeParentUtil ,
179179 getNodeAnchorPosition,
180+ getBlockDimensions,
180181 } = useNodeUtilities ( blocks )
181182
182183 /** Triggers immediate subflow resize without delays. */
@@ -1512,43 +1513,32 @@ const WorkflowContent = React.memo(() => {
15121513 if ( ! parentId ) return
15131514
15141515 setDisplayNodes ( ( currentNodes ) => {
1515- // Find all children of this container from current displayNodes
15161516 const childNodes = currentNodes . filter ( ( n ) => n . parentId === parentId )
15171517 if ( childNodes . length === 0 ) return currentNodes
15181518
1519- // Calculate dimensions using current positions from displayNodes
1520- // Match padding values from use-node-utilities.ts calculateLoopDimensions
1521- const headerHeight = 50
1522- const leftPadding = 16
1523- const rightPadding = 80
1524- const topPadding = 16
1525- const bottomPadding = 16
1526- const minWidth = CONTAINER_DIMENSIONS . DEFAULT_WIDTH
1527- const minHeight = CONTAINER_DIMENSIONS . DEFAULT_HEIGHT
1528-
15291519 let maxRight = 0
15301520 let maxBottom = 0
15311521
15321522 childNodes . forEach ( ( node ) => {
1533- // Use the dragged node's live position, others from displayNodes
15341523 const nodePosition = node . id === draggedNodeId ? draggedNodePosition : node . position
1524+ const { width : nodeWidth , height : nodeHeight } = getBlockDimensions ( node . id )
15351525
1536- // Get dimensions - use block store for height estimates
1537- const blockData = blocks [ node . id ]
1538- const nodeWidth = BLOCK_DIMENSIONS . FIXED_WIDTH
1539- const nodeHeight = blockData ?. height || node . height || BLOCK_DIMENSIONS . MIN_HEIGHT
1540-
1541- const rightEdge = nodePosition . x + nodeWidth
1542- const bottomEdge = nodePosition . y + nodeHeight
1543-
1544- maxRight = Math . max ( maxRight , rightEdge )
1545- maxBottom = Math . max ( maxBottom , bottomEdge )
1526+ maxRight = Math . max ( maxRight , nodePosition . x + nodeWidth )
1527+ maxBottom = Math . max ( maxBottom , nodePosition . y + nodeHeight )
15461528 } )
15471529
1548- const newWidth = Math . max ( minWidth , leftPadding + maxRight + rightPadding )
1549- const newHeight = Math . max ( minHeight , headerHeight + topPadding + maxBottom + bottomPadding )
1530+ const newWidth = Math . max (
1531+ CONTAINER_DIMENSIONS . DEFAULT_WIDTH ,
1532+ CONTAINER_DIMENSIONS . LEFT_PADDING + maxRight + CONTAINER_DIMENSIONS . RIGHT_PADDING
1533+ )
1534+ const newHeight = Math . max (
1535+ CONTAINER_DIMENSIONS . DEFAULT_HEIGHT ,
1536+ CONTAINER_DIMENSIONS . HEADER_HEIGHT +
1537+ CONTAINER_DIMENSIONS . TOP_PADDING +
1538+ maxBottom +
1539+ CONTAINER_DIMENSIONS . BOTTOM_PADDING
1540+ )
15501541
1551- // Update the container node's dimensions in displayNodes
15521542 return currentNodes . map ( ( node ) => {
15531543 if ( node . id === parentId ) {
15541544 const currentWidth = node . data ?. width || CONTAINER_DIMENSIONS . DEFAULT_WIDTH
@@ -1570,7 +1560,7 @@ const WorkflowContent = React.memo(() => {
15701560 } )
15711561 } )
15721562 } ,
1573- [ blocks ]
1563+ [ blocks , getBlockDimensions ]
15741564 )
15751565
15761566 /**
0 commit comments