diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 91668b744d4..3f58c9aef48 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -2581,24 +2581,24 @@ export class WorkspaceSvg rawViewport.left + rawViewport.width, ); + // Add the padding to the bounds so the element is scrolled comfortably + // into view. + bounds = bounds.clone(); + bounds.top -= padding; + bounds.bottom += padding; + bounds.left -= padding; + bounds.right += padding; + if ( bounds.left >= viewport.left && bounds.top >= viewport.top && bounds.right <= viewport.right && bounds.bottom <= viewport.bottom ) { - // Do nothing if the block is fully inside the viewport. + // Do nothing if the block with padding is fully inside the viewport. return; } - // Add some padding to the bounds so the element is scrolled comfortably - // into view. - bounds = bounds.clone(); - bounds.top -= padding; - bounds.bottom += padding; - bounds.left -= padding; - bounds.right += padding; - let deltaX = 0; let deltaY = 0;