Skip to content

Ignore insertion markers in getAllBlocks; add accessors for insertion markers#2243

Merged
rachel-fenichel merged 1 commit into
RaspberryPiFoundation:developfrom
rachel-fenichel:getAllBlocks_insertionMarkers
Feb 1, 2019
Merged

Ignore insertion markers in getAllBlocks; add accessors for insertion markers#2243
rachel-fenichel merged 1 commit into
RaspberryPiFoundation:developfrom
rachel-fenichel:getAllBlocks_insertionMarkers

Conversation

@rachel-fenichel

Copy link
Copy Markdown
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

Fixes #2236

Proposed Changes

Stop counting insertion markers in the results of getAllBlocks. Add an accessor for getting the current live insertion markers from a gesture.

It also would have worked to have an optional parameter to getAllBlocks, but I decided to leave its signature alone and do something a little more complicated but only in internal code. This way we don't add yet another thing to the external API.

Reason for Changes

See #2236

Test Coverage

Tested in the max blocks demo with uncompressed blockly.

Additional Information

This might also apply to workspace.getBlocksByType, getTopBlocks, etc. It's kind of unfortunate: there are good reasons for the blocks to be in the top blocks list, mostly related to behaving like perfectly normal blocks for connection and disconnection purposes, but in all other cases they're unwanted.

Comment thread core/workspace.js

// Insertion markers exist on the workspace for rendering reasons, but aren't
// "real" blocks from a developer perspective.
var filtered = blocks.filter(function(block) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be filtered at the getDescendent() and getChildren() level? I imagine we don't want insertion markers returned via those methods, either.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe? I can't tell where the right place for this code is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants