Skip to content

Dynamic blocks: default values for attributes aren't converted into html comments #7342

@katerlouis

Description

@katerlouis

Describe the bug
When an attribute isn't changed, the value will not be written into the serialized html comment, which in fact, makes it unaccessible for PHPs render_callback-function.

To Reproduce
Steps to reproduce the behavior:

  1. Make a custom block
  2. Add a sourceless attribute with default value
attributes: {
    myNumber: {
        type: "number",
        default: 1, // this number won't appear in the html comments
    }
}
  1. Do not alter the attribute
  2. Save the content
  3. var_dump() the $attribues in 'render_callback
    5b. or look into database, the html comment doesn't contain 'number'
  4. Be sad 'number' isn't there :'(

Expected behavior
To avoid syncing the defaults in both php and js, I expect gutenberg to save defaults into the html comment aswell.

Desktop (please complete the following information):

  • OS: MacOS High Sierra
  • Browser Doesn't matter
  • Version Doesn't matter

Additional context

  • Gutenberg Version 3.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Block APIAPI that allows to express the block paradigm.[Feature] ExtensibilityThe ability to extend blocks or the editing experience[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions