Skip to content

fix: reset initial connections before storing new ones#9982

Merged
mikeharv merged 2 commits into
RaspberryPiFoundation:mainfrom
mikeharv:reset-initial-connections
Jun 12, 2026
Merged

fix: reset initial connections before storing new ones#9982
mikeharv merged 2 commits into
RaspberryPiFoundation:mainfrom
mikeharv:reset-initial-connections

Conversation

@mikeharv

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes:

  1. With two connected blocks on the workspace, move one to a different connection and commit the move.
  2. Start moving the same block again, but hit escape before committing.
block_svg.ts:313 Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': The new child element contains the parent.
    at BlockSvg.setParent (block_svg.ts:313:44)

Proposed Changes

This change guarantees that we clear any stored initial connections before storing new ones.

Reason for Changes

The workspace could become completely unresponsive if a revert fails. In this case, after storing an initial child connection, the block was moved to a parent connection on the same block. When the next move occurs, the initial child connection was not cleared, resulting in two conflicting initial connections. Revert would then try to "re-connect" the blocks in two conflicting ways.

Test Coverage

Thanks to @maribethb for writing a new test that ensures we don't throw when a block move is reverted after storing both a child and parent connection for two different moves.

Additional Information

Alternative to #9980

It still seems like there is some cleanup that is missing (that endDrag does but revertDrag doesn't, but this can wait for now.

@mikeharv mikeharv requested a review from a team as a code owner June 12, 2026 14:07
@mikeharv mikeharv requested a review from maribethb June 12, 2026 14:07
@github-actions github-actions Bot added the PR: fix Fixes a bug label Jun 12, 2026
@mikeharv mikeharv merged commit 3c2b8b4 into RaspberryPiFoundation:main Jun 12, 2026
4 checks passed
@mikeharv mikeharv deleted the reset-initial-connections branch June 12, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants