From 4604c2fa5fd3834bf0bbb84d125a2125ffc4c702 Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Thu, 23 Oct 2025 06:47:12 +0200 Subject: [PATCH 1/2] Let table original position when still overlaps after making all attemps --- .../components/export-button/export-button.business.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index 765b62f7..be5333eb 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -92,10 +92,10 @@ export const placeTableWithoutOverlap = ( ): TableVm => { let newTable = table; let attempts = 0; - + while ( doesTableOverlap(newTable, tables) && - attempts < TABLE_CONST.MAX_PLACEMENT_ATTEMPTS + attempts < TABLE_CONST.MAX_PLACEMENT_ATTEMPTS ) { newTable = { ...newTable, @@ -113,6 +113,12 @@ export const placeTableWithoutOverlap = ( attempts++; } + // If relocated table still overlaps, restore original posotion. + if (doesTableOverlap(newTable, tables)) { + newTable.x = table.x; + newTable.y = table.y; + } + return newTable; }; From 3892a50f80240bfd5b06c1d64f8619ddbcf43f95 Mon Sep 17 00:00:00 2001 From: JuanBerrocal Date: Tue, 28 Oct 2025 06:41:56 +0100 Subject: [PATCH 2/2] Fix code to pass test: should properly adjusts tables to avoid overlap in complex scenarios --- .../toolbar/components/export-button/export-button.business.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pods/toolbar/components/export-button/export-button.business.ts b/src/pods/toolbar/components/export-button/export-button.business.ts index be5333eb..8f7fd991 100644 --- a/src/pods/toolbar/components/export-button/export-button.business.ts +++ b/src/pods/toolbar/components/export-button/export-button.business.ts @@ -114,7 +114,7 @@ export const placeTableWithoutOverlap = ( } // If relocated table still overlaps, restore original posotion. - if (doesTableOverlap(newTable, tables)) { + if ((newTable.width) && (newTable.width > TABLE_CONST.TABLE_SHIFT_DISTANCE) && doesTableOverlap(newTable, tables)) { newTable.x = table.x; newTable.y = table.y; }