From dee27b905dd4cfbae1f564192d594e401c19b468 Mon Sep 17 00:00:00 2001 From: RoboErikG Date: Mon, 28 Apr 2025 15:24:57 -0700 Subject: [PATCH] fix: Support RTL in WorkspaceSvg.scrollIntoBounds (#8936) * feat: add support for RTL to scrollBoundsIntoView * Add additional comment --- core/workspace_svg.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 91668b744..e8d411651 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -2603,15 +2603,28 @@ export class WorkspaceSvg let deltaY = 0; if (bounds.left < viewport.left) { - deltaX = viewport.left - bounds.left; + deltaX = this.RTL + ? Math.min( + viewport.left - bounds.left, + viewport.right - bounds.right, // Don't move the right side out of view + ) + : viewport.left - bounds.left; } else if (bounds.right > viewport.right) { - deltaX = viewport.right - bounds.right; + deltaX = this.RTL + ? viewport.right - bounds.right + : Math.max( + viewport.right - bounds.right, + viewport.left - bounds.left, // Don't move the left side out of view + ); } if (bounds.top < viewport.top) { deltaY = viewport.top - bounds.top; } else if (bounds.bottom > viewport.bottom) { - deltaY = viewport.bottom - bounds.bottom; + deltaY = Math.max( + viewport.bottom - bounds.bottom, + viewport.top - bounds.top, // Don't move the top out of view + ); } deltaX *= scale;