Skip to content

Pasting copied blocks with shared IDs causes block disappearance, possibly due to event mirroring #9226

@mikeharv

Description

@mikeharv

Check for duplicates

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

Description

When using a rendered workspace that mirrors events into a unrendered workspace, pasting blocks that were copied from another function can result in data loss. Specifically, the original copied block disappears.

This seems to occur because the copied block retains its original ID, which exists in both workspaces. Upon pasting, the mirrored event overwrites the block in the hidden workspace due to the ID collision.

I can work around the issue by overriding toCopyData() and setting saveIds: false during block serialization, which prevents ID collisions. (code-dot-org/code-dot-org#67021)

We're using a plugin setup that includes:

  • cross-tab plugin
  • shareable procedures

We have the following workspaces

  • main student workspace
  • hidden procedures workspace
  • function editor workspace (with event mirroring to hidden workspace)

I am wondering whether Blockly has a clear reason for including block ids in copied blocks or whether they could or should be excluded.

Reproduction steps

Create two functions at https://studio.code.org/projects/spritelab, then:

  1. In the function editor workspace, copy a block.
  2. Switch to a different function.
  3. Paste the copied block.
  4. Observe that the original block disappears from the hidden workspace.

Stack trace

Screenshots

No response

Browsers

No response

Metadata

Metadata

Assignees

Labels

carryoverissue: bugDescribes why the code or behaviour is wrong

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions