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

Global styles: block level styles are enqueued twice #42206

Closed
ramonjd opened this issue Jul 7, 2022 · 0 comments · Fixed by #42207
Closed

Global styles: block level styles are enqueued twice #42206

ramonjd opened this issue Jul 7, 2022 · 0 comments · Fixed by #42207
Assignees
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Comments

@ramonjd
Copy link
Member

ramonjd commented Jul 7, 2022

Description

Since #42005, global block styles are enqueued twice:

  1. In global-styles-inline-css
  2. In wp-block-social-links-inline-css

This causes duplicate styles in styles.blocks[ $block_name ] rendered to the HTML.

Before

<style id='wp-block-social-links-inline-css'>
.wp-block-social-links {
	background-color: yellow;
	color: red;
	margin: 100px;
	padding: 150px;
}

</style>

After

<style id='global-styles-inline-css'>

/* ... lots of global styles */

.wp-block-social-links {
	background-color: yellow;
	color: red;
	margin: 100px;
	padding: 150px;
}

/* ... lots more global styles */
</style>

<!-- ... a bunch of stuff... -->

<style id='wp-block-social-links-inline-css'>
.wp-block-social-links {
	background-color: yellow;
	color: red;
	margin: 100px;
	padding: 150px;
}

</style>

Step-by-step reproduction instructions

Add some block styles to your theme.json. Any block will do.

I'm using emptytheme and the Social links block as an example.

Example theme.json
{
	"version": 2,
	"settings": {
		"appearanceTools": true,
		"layout": {
			"contentSize": "840px",
			"wideSize": "1100px"
		}
	},
	"styles": {
		"spacing": {
		},
		"blocks": {
			"core/social-links": {
				"spacing": {
					"blockGap": "55px",
					"margin": "100px",
					"padding": "150px"
				},
				"color": {
					"text": "red",
					"background": "yellow"
				}
			}
		}
	},
	"patterns": [
		"short-text-surrounded-by-round-images",
		"partner-logos"
	]
}

Create a post with that block and publish it.

Example block code
<!-- wp:social-links -->
<ul class="wp-block-social-links"><!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->

<!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /--></ul>
<!-- /wp:social-links -->

Inspect the block HTML and see that the styles are applied twice.

Screenshots, screen recording, code snippet

Screen Shot 2022-07-07 at 11 33 15 am

Environment info

  • WordPress 6.0
  • Gutenberg 13.6.0
  • Any block-based theme

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

@ramonjd ramonjd added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jul 7, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 7, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
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 [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants