More Scratch Blocks fixes#482
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Scratch Blocks–related regressions affecting keyboard input routing and workspace switching, ensuring the VM continues to receive intended key events and that workspace reloads don’t emit spurious Blockly events.
Changes:
- Adjust keyboard event filtering so SVG-targeted (Blockly workspace) keydowns are forwarded to the VM even when a block has Blockly focus.
- Update unit test expectations for VM keyboard event forwarding from the Blockly SVG workspace.
- During workspace reload on sprite switch, disable/enable Blockly event generation instead of removing/re-adding the VM block listener.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/scratch-gui/test/unit/util/vm-listener-hoc.test.jsx | Updates unit test to assert SVG (Blockly workspace) keydowns are forwarded to the VM. |
| packages/scratch-gui/src/lib/vm-listener-hoc.jsx | Removes ScratchBlocks-focused filtering; forwards SVG-targeted keydowns to VM while still ignoring HTML input targets. |
| packages/scratch-gui/src/containers/blocks.jsx | Switches from listener removal to ScratchBlocks.Events.disable()/enable() during workspace reload to avoid async-queued event leakage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Test report for scratch-gui 2 files 63 suites 10m 14s ⏱️ Results for commit 08016f80. ♻️ This comment has been updated with latest results. |
bddd0f2 to
08016f8
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes two Scratch Blocks / Blockly integration issues in Scratch GUI: (1) keyboard events from the Blockly SVG workspace were being overly filtered and not reaching the VM in some focus states, and (2) switching workspaces during sprite changes could leak queued async Blockly events to the VM.
Changes:
- Adjust VM keyboard event forwarding to always allow SVG-targeted (Blockly workspace) keydown events through to the VM.
- Switch workspace reload suppression from temporarily removing listeners to disabling/enabling Blockly events around workspace reload.
- Add unit coverage for ensuring
ScratchBlocks.Events.enable()is always called after a workspace reload attempt (success or failure).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/scratch-gui/test/unit/util/vm-listener-hoc.test.jsx | Updates keyboard forwarding expectations to match the new SVG-focused behavior. |
| packages/scratch-gui/test/unit/containers/blocks.test.js | Adds unit tests ensuring Blockly events are re-enabled even if workspace load/parsing throws. |
| packages/scratch-gui/src/lib/vm-listener-hoc.jsx | Removes isContentNodeFocused gating so SVG-targeted keydown events always reach the VM. |
| packages/scratch-gui/src/containers/blocks.jsx | Disables/enables Blockly events during workspace reload and exports Blocks for unit testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Resolves
Proposed Changes
Reason for Changes
Test Coverage
Tested locally with the "Eat the Pi!" project, which is sensitive to both of these issues.