Skip to content

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

Closed

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

Activity

  1. added
    [Type] Bug
    [Block] Image
    Global Styles
    [Feature] Interactivity API
    on Sep 19, 2023
  2. changed the title [-]Image: 'False' values are not read when use for lightbox configuration in `theme.json`[/-] [+]Image: 'False' values are not read when used for lightbox configuration in `theme.json`[/+] on Sep 19, 2023
  3. changed the title [-]Image: 'False' values are not read when used for lightbox configuration in `theme.json`[/-] [+]Image: 'False' values are not persisted when used for lightbox configuration in `theme.json`[/+] on Sep 19, 2023
  4. changed the title [-]Image: 'False' values are not persisted when used for lightbox configuration in `theme.json`[/-] [+]Image: 'False' values are not persisted in memory when used for lightbox configuration in `theme.json`[/+] on Sep 19, 2023
  5. changed the title [-]Image: 'False' values are not persisted in memory when used for lightbox configuration in `theme.json`[/-] [+]Image: `False` values are not persisted in memory when used for lightbox configuration in `theme.json`[/+] on Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global Styles[Block] Image[Feature] Interactivity API[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions