Open andersnoren opened 5 months ago
Thanks for opening this issue! It's very similar to https://github.com/WordPress/gutenberg/issues/56554 which asks for the UI to be available in global styles. In both cases I believe the blocker is that the Gallery block includes ad hoc output of default rules for backwards compatibility, which interferes with opting-in for global styles. One potential option could be to perform a look-up to see whether or not a global styles rule for gap is set before outputting the fallback rules. That should be possible in the PHP-side, however in the block editor would likely require something like https://github.com/WordPress/gutenberg/pull/59929 to land first, in order to be able to check whether or not the global styles value is set before outputting the rules via JS.
It would be really good to address this one way or another, though, as not being able to set global gap for Gallery blocks is quite a missing feature!
Description
If you set a custom
blockGap
value on the gallery block in theme.json, that CSS is output in the editor and on the front-end, but it's overwritten by the CSS for the default value which has a higher specificity.This is the CSS output for the theme.json value, with a 0.1.0 specificity:
And this is the CSS output for the default value, with a 0.2.0 specificity:
Expected behavior
The blockGap value set in theme.json should overwrite the default value.
Step-by-step reproduction instructions
styles.blocks.core/gallery.spacing
, and add"blockGap": "200px"
.Screenshots, screen recording, code snippet
Environment info
WordPress 6.5 With or without Gutenberg 18.0.0 active Twenty Twenty-Four 1.1
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