Fix for Bug: "Insert blocks by name" creates two undo points when placing a block - #9029
Open
griffpatch wants to merge 2 commits into
Open
Fix for Bug: "Insert blocks by name" creates two undo points when placing a block#9029griffpatch wants to merge 2 commits into
griffpatch wants to merge 2 commits into
Conversation
…undo point Previously, `BlockCreate` was fired before `onDragStart`. Blockly's `onDragStart` calls `Events.setGroup(true)` internally, creating a new event group for the drag. The `BlockCreate` had no group, so it became a separate undo point from the `BlockMove` fired on drop — resulting in two undo steps: one placing the block at the popup cursor, then another at the drop position. Fix: move the `BlockCreate` fire to after `onDragStart` (in both the new and old Blockly paths). The drag group is still active at that point, so `BlockCreate` and `BlockMove` share the same group and undo together as a single step.
mxmou
reviewed
Aug 4, 2026
mxmou
left a comment
Member
There was a problem hiding this comment.
The main changes look good and the fix works, but I don't understand some of the added ts-ignore comments.
mxmou
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug: "Insert blocks by name" creates two undo points when placing a block
Summary
When using the Insert blocks by name addon to place a block, pressing Ctrl+Z once doesn't remove it - instead the block jumps back to where your cursor was when you opened the search popup. A second Ctrl+Z is needed to actually remove the block. Expected behaviour is one Ctrl+Z removes the block entirely.
Bug: "Insert blocks by name" creates two undo points when placing a block
Summary
When using the Insert blocks by name addon to place a block, pressing Ctrl+Z once doesn't remove it - instead the block jumps back to where your cursor was when you opened the search popup. A second Ctrl+Z is needed to actually remove the block. Expected behaviour is one Ctrl+Z removes the block entirely.
Steps to reproduce
Expected behaviour
A single Ctrl+Z removes the block entirely, as it does when dragging a block from the palette.
Root cause
The addon fires a
BlockCreateevent before starting the drag. Blockly's drag start creates a new event group for the drag, leavingBlockCreatein a separate group - so Scratch sees two distinct undo steps: one for the creation (at the popup cursor position), and one for the drop (where you released the block).Fix
Fire
BlockCreateafteronDragStartso it joins the drag's event group.BlockCreateandBlockMovethen undo together as a single step, matching the behaviour of blocks dragged from the palette.