Skip to content

fix: Fix nested block duplication bumping parent stack - #10682

Open
matthewalberto wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
matthewalberto:fix/paste-nested-block-bumps-stack
Open

matthewalberto wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
matthewalberto:fix/paste-nested-block-bumps-stack

Conversation

@matthewalberto

@matthewalberto matthewalberto commented Nov 13, 2026 •

Copy link
Copy Markdown

The basics

The details

Resolves

Fixes #10675.

Proposed Changes

Prevent duplicate blocks from triggering unintended stack adjustments during their initial render.

Defer bumping other blocks until after the duplicate has been positioned.

Preserve the initial render step so Blockly can calculate the duplicate's connection positions correctly.

Add regression tests covering duplication of nested blocks with children.

Reason for Changes

When duplicating a block nested inside another block, the duplicate initially appears directly on top of the original. Blockly is expected to move the duplicate down and to the right.

Previously, Blockly performed bumping during the initial render, before repositioning the duplicate. Because the duplicate's edges aligned with the original block's interior, the original stack was bumped instead, leaving the duplicate in its initial position.

Deferring bumping until after repositioning ensures that the correct blocks are moved.

Test Coverage

Full test suite: Added 4 regression tests. The original implementation fails 3 of the 4 new tests and passes 4044 tests overall. With this fix, all 4047 tests pass.

Mutation testing: All 7 deliberate breakages were caught. An additional test was added after one breakage escaped the initial run.

Lint and formatting: Clean on all 3 changed files. The only failure in the wider lint run is caused by Windows line endings in unrelated files; CI runs on Linux.

Not tested: Real-browser behavior, Linux locally, and alternative renderers.

Documentation

No documentation changes are needed.

Additional Information

Claude Code (Claude Opus 5.5) was used collaboratively throughout the process, including reproducing the bug, implementing the fix, writing the four regression tests, and performing validation checks. All PR description text was written independently by the human contributor.

@matthewalberto
matthewalberto requested a review from a team as a code owner November 13, 2026 03:17
@github-actions github-actions Bot added the PR: fix Fixes a bug label Nov 13, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome! It looks like this is your first pull request in Blockly, so here are a couple of tips:

  • You can find tips about contributing to Blockly and how to validate your changes on our developer site.
  • We use conventional commits to make versioning the package easier. Make sure your commit message is in the proper format or learn how to fix it.
  • If any of the other checks on this PR fail, you can click on them to learn why. It might be that your change caused a test failure, or that you need to double-check the style guide.
    Thank you for opening this PR! A member of the Blockly team will review it soon.

@github-actions github-actions Bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels Nov 13, 2026

This branch has not been deployed

No deployments
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.

Duplicating a nested block that has children bumps the parent stack

2 participants