scratch-blocks 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.mjs +1 -1
- package/package.json +1 -1
- package/src/index.ts +15 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -157,3 +157,18 @@ contextMenuItems.registerDuplicateBlock()
|
|
|
157
157
|
Blockly.ContextMenuRegistry.registry.unregister('workspaceDelete')
|
|
158
158
|
contextMenuItems.registerDeleteAll()
|
|
159
159
|
Blockly.comments.CommentView.defaultCommentSize = new Blockly.utils.Size(200, 200)
|
|
160
|
+
|
|
161
|
+
// When the focused block is deleted and has no parent or nearby neighbor,
|
|
162
|
+
// Blockly falls back to focusing the first/topmost block in the workspace,
|
|
163
|
+
// which triggers a scroll to that block. In Scratch, focus should fall back
|
|
164
|
+
// to the workspace itself (whose onNodeFocus is a no-op) rather than to a
|
|
165
|
+
// specific block, so deleting a block doesn't reset the scroll position.
|
|
166
|
+
// We may need to re-evaluate this when we explicitly work on keyboard navigation.
|
|
167
|
+
const originalGetRestoredFocusableNode =
|
|
168
|
+
Blockly.WorkspaceSvg.prototype.getRestoredFocusableNode
|
|
169
|
+
Blockly.WorkspaceSvg.prototype.getRestoredFocusableNode = function (
|
|
170
|
+
previousNode,
|
|
171
|
+
) {
|
|
172
|
+
if (!previousNode && !this.isFlyout) return null
|
|
173
|
+
return originalGetRestoredFocusableNode.call(this, previousNode)
|
|
174
|
+
}
|