Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
drwsmth opened this issue Jun 9, 2022 · 4 comments
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.

Comments

@drwsmth
Copy link

drwsmth commented Jun 9, 2022

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

@annezazu
Copy link
Contributor

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

@annezazu annezazu added Needs Technical Feedback Needs testing from a developer perspective. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jun 17, 2022
@jorgefilipecosta
Copy link
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!

@jorgefilipecosta jorgefilipecosta added [Status] Needs More Info Follow-up required in order to be actionable. and removed Needs Technical Feedback Needs testing from a developer perspective. labels Jun 23, 2022
@github-actions
Copy link

github-actions bot commented Jul 9, 2022

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.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Jul 9, 2022
@mrfoxtalbot
Copy link

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!

@mrfoxtalbot mrfoxtalbot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.
Projects
None yet
Development

No branches or pull requests

4 participants