Skip to content

[block-shareable-procedures] Toolbox breaks after deleting functions #2484

@mikeharv

Description

@mikeharv

Check for duplicates

  • I have searched for similar issues before opening a new one.

Component

The block-shareable-procedures plugin has a bug where the dynamic Functions category cannot be opened.

Description

The bug happens when a call block is deleted automatically alongside its definition from the workspace. The error seems to suggest that Blockly has attempted to delete the same call block twice during clearOldBlocks(). When the definition block is disposed, this the call block below it to delete itself via doProcedureUpdate.

This is impacting all of Code.org's Blockly labs, even those that just use a single workspace. A local workaround seems possible. By overriding doProcedureUpdate, I was able to check !this.workspace.isFlyout before allowing the this.dispose() call to go through. I'm not sure whether this is the best solution or not, but it does unblock us for now.

Reproduction steps

  1. Go to https://google.github.io/blockly-samples/plugins/block-shareable-procedures/test/index
  2. Add a function definition and a function call to either workspace.
  3. Delete the function definition
  4. Attempt to re-open the Functions category of the toolbox

The flyout is not populated and an error is thrown:

Uncaught Error: Block not present in workspace's list of top-most blocks.
    at WorkspaceSvg$$module$build$src$core$workspace_svg.removeTopBlock

Stack trace

blockly_compressed.js:1126 Uncaught Error: Block not present in workspace's list of top-most blocks.
    at WorkspaceSvg$$module$build$src$core$workspace_svg.removeTopBlock (blockly_compressed.js:1126:10)
    at WorkspaceSvg$$module$build$src$core$workspace_svg.removeTopBlock (blockly_compressed.js:1181:339)
    at BlockSvg$$module$build$src$core$block_svg.dispose (blockly_compressed.js:973:156)
    at BlockSvg$$module$build$src$core$block_svg.dispose (blockly_compressed.js:1234:7)
    at VerticalFlyout$$module$build$src$core$flyout_vertical.clearOldBlocks (blockly_compressed.js:1415:401)
    at VerticalFlyout$$module$build$src$core$flyout_vertical.show (blockly_compressed.js:1409:481)
    at Toolbox$$module$build$src$core$toolbox$toolbox.updateFlyout_ (blockly_compressed.js:1627:387)
    at Toolbox$$module$build$src$core$toolbox$toolbox.setSelectedItem (blockly_compressed.js:1626:103)
    at Toolbox$$module$build$src$core$toolbox$toolbox.onClick_ (blockly_compressed.js:1615:97)
    at HTMLDivElement.f (blockly_compressed.js:85:149)

Screenshots

Image

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions