@@ -79,22 +79,11 @@ export function calculateNestedAreaDimensions(
79
79
let totalNestedHeight = 0 ;
80
80
let totalNestedWidth = 0 ;
81
81
82
- // Recursively process all nested children and their descendants
83
- const processNestedChain = ( nodeId : string ) => {
84
- const node = allNodes . get ( nodeId ) ;
85
- if ( ! node ) return ;
86
-
87
- const { h, w } = calculateCompleteSubtreeDimensions ( nodeId , allNodes , memoMap ) ;
82
+ // Process only nested children and their full subtrees
83
+ children . nested . forEach ( nestedChild => {
84
+ const { h, w } = calculateCompleteSubtreeDimensions ( nestedChild . brick . uuid , allNodes , memoMap ) ;
88
85
totalNestedHeight += h ;
89
86
totalNestedWidth = Math . max ( totalNestedWidth , w ) ;
90
-
91
- const childChildren = getNodeChildren ( nodeId , allNodes ) ;
92
- childChildren . nested . forEach ( child => processNestedChain ( child . brick . uuid ) ) ;
93
- childChildren . stacked . forEach ( child => processNestedChain ( child . brick . uuid ) ) ; // Include stacked chains as part of nested area
94
- } ;
95
-
96
- children . nested . forEach ( nestedChild => {
97
- processNestedChain ( nestedChild . brick . uuid ) ;
98
87
} ) ;
99
88
100
89
const result = { w : totalNestedWidth , h : totalNestedHeight } ;
@@ -245,6 +234,17 @@ export function debugBoundingBoxCalculation(
245
234
console . log ( ` Original: ${ childOriginal . w } ×${ childOriginal . h } ` ) ;
246
235
console . log ( ` Calculated: ${ childBB ?. w || 0 } ×${ childBB ?. h || 0 } ` ) ;
247
236
} ) ;
237
+
238
+ // Additional debug for stacked children affecting nested area
239
+ console . log ( ` Stacked children affecting nested area:` ) ;
240
+ children . stacked . forEach ( ( child , index ) => {
241
+ const childBB = bbMap . get ( child . brick . uuid ) ;
242
+ const childLabel = child . brick . name || child . brick . type || 'Unknown' ;
243
+ const childOriginal = child . brick . boundingBox ;
244
+ console . log ( ` ${ index + 1 } . "${ childLabel } ":` ) ;
245
+ console . log ( ` Original: ${ childOriginal . w } ×${ childOriginal . h } ` ) ;
246
+ console . log ( ` Calculated: ${ childBB ?. w || 0 } ×${ childBB ?. h || 0 } ` ) ;
247
+ } ) ;
248
248
} ) ;
249
249
250
250
console . log ( '\n=== END DETAILED DEBUG ===\n' ) ;
0 commit comments