feat: add undo and redo shortcuts for deleting blocks#7714
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7714 +/- ##
==========================================
+ Coverage 54.12% 54.19% +0.06%
==========================================
Files 172 172
Lines 57072 57133 +61
==========================================
+ Hits 30892 30964 +72
+ Misses 26180 26169 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b2a2c79 to
13755b4
Compare
|
This PR has merge conflicts with Please rebase your branch: # Add upstream remote (one-time setup)
git remote add upstream https://github.com/sugarlabs/musicblocks.git
# Fetch latest master and rebase
git fetch upstream
git rebase upstream/master
# Resolve any conflicts, then:
git push --force-with-lease origin YOUR_BRANCH
|
|
@Chaitu7032 thanks for this critical reveiw, i have fixed it ,now take a look . |
|
@walterbender @zealot-zew what u guys think about this feature? |
|
I've not tested your code yet. Will do over the weekend. This has been tried numerous times but we've yet to strike the right balance in terms of what undo granularity should be. Each block movement? Only block movements that cause a connection change? Values in arg blocks? etc. I'd be curious as to how you determined what a change consists of. |
|
Thanks for the feedback! @walterbender Regarding the Ctrl+Z UX issue, there wasn't any specific reason behind requiring users to wait between consecutive undo operations. I'll look into improving that behavior so multiple undo actions can be triggered seamlessly. I'll also start working on the other points you mentioned, including restoring deleted blocks to their original position and supporting undo for block value changes, and I'll update the PR as I make progress. |
|
Hi @lavjeetrai |
There was only one bug in that PR that adding a new block directly in the existing block and undo that leads to white space. This issue is mentioned in the comments of that PR as well. So if you wish to work on that PR, you can do that, I will merge your commits into the same. |
|
Hi @stutijain2006, thanks for letting me know and for sharing your PR! Sorry, but I'm already familiar with the implementation in my current PR, and I don't have enough time to go through the older PR in detail. I think it's more efficient for me to continue with my current approach. That said, since you've already worked on this, I'd really appreciate your help if I run into any issues or need guidance while finishing it. Sorry and Thanks again! |
That's completely fine. No issues. Keep on working on your PR, and can ask me for help if you face any difficult in between. |


Description
This PR upgrades the
Ctrl+ZandCtrl+Ykeyboard shortcuts to support a generalized undo/redo history using the Command Pattern. Users can now flawlessly revert and reapply both block movements and block deletions.Screen.Recording.2026-07-01.233456.mp4
Key Changes
Action History Stack: Replaced the primitive
trashStackssystem with anactionHistoryandredoActionHistoryarray inblocks.jsto log generalized{ type: "move" | "trash", ... }objects.Coordinate Tracking: Added
mousedowncoordinate tracking to record precise start/end locations of blocks when dragged across the canvas.Feature