From dcd2d0e539f2b7aa34b58969d5dc812e7848800c Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Thu, 27 Feb 2025 13:04:37 -0800 Subject: [PATCH] fix: Fix a bug where selection outlines could be cut off when connecting blocks. (#8789) --- core/rendered_connection.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/rendered_connection.ts b/core/rendered_connection.ts index f73dc0628..c1d97dcdd 100644 --- a/core/rendered_connection.ts +++ b/core/rendered_connection.ts @@ -533,6 +533,21 @@ export class RenderedConnection extends Connection { childBlock.updateDisabled(); childBlock.queueRender(); + // If either block being connected was selected, visually un- and reselect + // it. This has the effect of moving the selection path to the end of the + // list of child nodes in the DOM. Since SVG z-order is determined by node + // order in the DOM, this works around an issue where the selection outline + // path could be partially obscured by a new block inserted after it in the + // DOM. + const selection = common.getSelected(); + const selectedBlock = + (selection === parentBlock && parentBlock) || + (selection === childBlock && childBlock); + if (selectedBlock) { + selectedBlock.removeSelect(); + selectedBlock.addSelect(); + } + // The input the child block is connected to (if any). const parentInput = parentBlock.getInputWithBlock(childBlock); if (parentInput) {