Skip to content

Non-core block styles defined in theme.json currently being filtered-out before rendering #41614

Closed as not planned

Description

@drwsmth

Description

When adding block styles for non-core blocks in theme.json, I expect styles to populate in the editor and front-end in a similar fashion to core blocks.

Seems that since #40185 was merged into Gutenberg 13.1, this is no longer happening — is this intended behaviour?

Step-by-step reproduction instructions

  1. Install the Gutenberg plugin
  2. Install a plugin which enqueues custom blocks (e.g. Share on Twitter Block by @richtabor
  3. Add a block style in theme.json for the block in question. In this case, for example, {"styles":{"blocks":{"tabor/share-on-twitter":{"color":{"background":"rebeccapurple","text":"white"},"border":{"radius":"10px"},"typography":{"fontSize":"2rem"}}}}}
  4. Add a block style in theme.json for a core block. For example, {"styles":{"blocks":{"core/paragraph":{"color":{"text":"teal"},"typography":{"fontSize":"2rem"}}}}}
  5. Add both blocks into a new page — notice that the core styles are parsed, but the non-core block styles aren't.
  6. In the plugin file compat/wordpress-6.0/block-editor-settings.php on line 85, remove the if-condition wrapping $styles_without_existing_global_styles[] = $style;
  7. Non-core block styles are now successfully being parsed.

Screenshots, screen recording, code snippet

Before making the change listed above in compat/wordpress-6.0/block-editor-settings.php on line 85

Pre

After making the change listed above in compat/wordpress-6.0/block-editor-settings.php on line 85

Post

Environment info

  • Wordpress 6.01 (tested and replicated on 5.9.3 and 6.0)
  • Gutenberg 13.4 (tested and replicated on 13.1 RC1, 13.1, 13.2 and 13.3)
  • macOS Monterray 12.3.1, Safari 15.4, Firefox 102

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. annezazu commented on Jun 17, 2022

    @annezazu
    Contributor

    @jorgefilipecosta perhaps you have some insights here? I know André is out still!

  2. added
    Needs Technical Feedback
    Global Styles
    on Jun 17, 2022
  3. jorgefilipecosta commented on Jun 23, 2022

    @jorgefilipecosta
    Member

    Hi @drwsmth,
    I'm not able to reproduce this issue. I applied the following theme.json

    {
    	"version": 2,
    	"styles": {
    		"blocks": {
    			"tabor/share-on-twitter": {
    				"color": {
    					"background":"rebeccapurple",
    					"text":"white"
    				},
    				"border": {
    					"radius":"10px"
    				},
    				"typography": {
    					"fontSize":"2rem"
    				}
    			},
    			"core/paragraph":{
    				"color":{
    					"text":"teal"
    				},
    				"typography":{
    					"fontSize": "2rem"
    				}
    			}
    		}
    	}
    }
    

    And both "Share on Twitter Block" and the paragraph look as expected. Could you please share the minimal theme.json file where you are able to reproduce the issue?

    Thank you in advance!

  4. added
    [Status] Needs More Info
    and removed
    Needs Technical Feedback
    on Jun 23, 2022
  5. github-actions commented on Jul 9, 2022

    @github-actions

    Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

  6. added
    [Status] Stale
    on Jul 9, 2022
  7. mrfoxtalbot commented on Sep 19, 2022

    @mrfoxtalbot

    This issue has not had any activity for a while and I cannot reproduce this either. I am going to close this but please feel free to reopen it if you can provide more details, @drwsmth. Thank you!

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[Status] Needs More Info[Status] Stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions