@@ -357,7 +357,6 @@ export function hasFinitePosition(block: BlockState): boolean {
357357function noteOverlappedBlockBefore (
358358 previousBlocks : Record < string , BlockState > ,
359359 noteId : string ,
360- noteDimensions : { width : number ; height : number } ,
361360 blockId : string
362361) : boolean {
363362 const previousNote = previousBlocks [ noteId ]
@@ -368,7 +367,9 @@ function noteOverlappedBlockBefore(
368367 // so it could not have overlapped anything before this pass.
369368 if ( ! hasFinitePosition ( previousNote ) || ! hasFinitePosition ( previousBlock ) ) return false
370369
371- const noteBox = createBoundingBox ( previousNote . position , noteDimensions )
370+ // Derive dimensions from the prior blocks so a resize between passes does not
371+ // pair new dimensions with the old position.
372+ const noteBox = createBoundingBox ( previousNote . position , getNoteDimensions ( previousNote ) )
372373 const blockBox = createBoundingBox ( previousBlock . position , getBlockMetrics ( previousBlock ) )
373374 return boxesOverlap ( blockBox , noteBox )
374375}
@@ -415,7 +416,9 @@ export function resolveNoteOverlaps(
415416
416417 for ( const id of groupIds ) {
417418 const block = blocks [ id ]
418- if ( ! block ) continue
419+ // Skip non-finite positions so corrupted coordinates never propagate into
420+ // minX / maxBottom (and therefore into relocated note positions).
421+ if ( ! block || ! hasFinitePosition ( block ) ) continue
419422
420423 if ( block . type === NOTE_BLOCK_TYPE ) {
421424 noteIds . push ( id )
@@ -450,7 +453,7 @@ export function resolveNoteOverlaps(
450453 const needsRelocation = obstacles . some ( ( { id : blockId , box } ) => {
451454 if ( ! boxesOverlap ( box , noteBox ) ) return false
452455 if ( previousBlocks ) {
453- return ! noteOverlappedBlockBefore ( previousBlocks , id , dimensions , blockId )
456+ return ! noteOverlappedBlockBefore ( previousBlocks , id , blockId )
454457 }
455458 return true
456459 } )
0 commit comments