Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty comments not saved during serialization #4960

Closed
jschanker opened this issue Jun 28, 2021 · 3 comments
Closed

Empty comments not saved during serialization #4960

jschanker opened this issue Jun 28, 2021 · 3 comments
Labels
issue: bug Describes why the code or behaviour is wrong

Comments

@jschanker
Copy link
Contributor

Describe the bug

If the comment for a block contains no text (even if pinned), this block state will not be serialized.

To Reproduce

Steps to reproduce the behavior:

  1. Go to the Blockly Playground,
  2. Import the following XML:
<xml xmlns="https://developers.google.com/blockly/xml">
  <block type="text_print" x="100" y="100">
    <comment pinned="true" h="80" w="160"></comment>
  </block>
</xml>
  1. Export the XML. Notice that the comment element is removed.

Expected behavior

The empty comment should be serialized.

@jschanker jschanker added issue: triage Issues awaiting triage by a Blockly team member issue: bug Describes why the code or behaviour is wrong labels Jun 28, 2021
@alschmiedt alschmiedt removed the issue: triage Issues awaiting triage by a Blockly team member label Jul 3, 2021
@BeksOmega
Copy link
Collaborator

I think this is actually intentional. The idea being, if the comment doesn't provide any information to the user, you might as well make the save file a tiny bit smaller.

But I'm definitely open to changing this when I do some other serialization work this quarter. Do you have a use case for saving the empty comments?

@jschanker
Copy link
Contributor Author

That makes sense, and I don't have any practical use case for saving the empty comments. I was just thinking if someone did something like the following to refresh the workspace, the loss of comments might be unexpected:

Blockly.Xml.clearWorkspaceAndLoadFromXml(Blockly.Xml.workspaceToDom(workspace), workspace);

Closing as WAI.

@jschanker
Copy link
Contributor Author

Just for some context, this is how I refreshed the workspace before I knew about the render method (or before it existed?). I needed it when I used newBlock for converting textual code to blocks to see the new blocks appear. On a tangential note that might be useful for anyone who had forked the Blockly repository a number of years ago before this was necessary, when creating new blocks, initModel or initSvg needs to be called on a block after creating it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

No branches or pull requests

3 participants