Skip to content

Image: False values are not persisted in memory when used for lightbox configuration in theme.json #54638

@artemiomorales

Description

@artemiomorales

Description

If you set the following in your theme.json...

"settings": {
    "blocks": {
        "core/image": {
            "lightbox": {
                "enabled": false,
                "allowEditing" false
            }
        }
    }
}

...rather than persisting as false in the in-memory representation of the theme.json, these values are filtered out.

While functionally these values being undefined rather than false may result in the same behavior in most cases, this appears to be a bug and makes it difficult to achieve consistency in #54544 and #54635.

Step-by-step reproduction instructions

  1. In the screen-block.js file, add a console.log for rawSettings around line 95.
  2. Open your web inspector and go to the Image settings in the Global Styles.
  3. See that the lightbox.allowEditing: true from the default Gutenberg theme.json is visible in the logged statement as expected.
Screenshot 2023-09-19 at 7 26 42 PM
  1. Modify your theme's theme.json to include the following setting to overwrite the default allowEditing value:
"settings": {
    "blocks": {
        "core/image": {
            "lightbox": {
                "allowEditing" false
            }
        }
    }
}
  1. Revisit the Image settings in the Global Styles, and see that the rawSettings no longer contains a value for lightbox at all.
Screenshot 2023-09-19 at 7 30 20 PM

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Block] ImageAffects the Image Block[Feature] Interactivity APIAPI to add frontend interactivity to blocks.[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions