Skip to content

Fix: Prevent empty CSS rules when blockGap is null in theme.json#71530

Open
devansh016 wants to merge 2 commits intoWordPress:trunkfrom
devansh016:empty-rules-blockgap
Open

Fix: Prevent empty CSS rules when blockGap is null in theme.json#71530
devansh016 wants to merge 2 commits intoWordPress:trunkfrom
devansh016:empty-rules-blockgap

Conversation

@devansh016
Copy link
Copy Markdown
Contributor

@devansh016 devansh016 commented Sep 6, 2025

What?

#71527
Prevents empty CSS rules from being generated when blockGap is set to null in theme.json.

Why?

This PR fixes a bug where invalid CSS (e.g., margin-block-start: ;) was output when blockGap was null, causing W3C validation errors.

How?

Adds a conditional check to skip generating blockGap-related CSS if the value is null or empty.

Testing Instructions

  1. Set blockGap: null in your theme’s theme.json.
  2. Add blocks (e.g., calendar, search) to a post or page.
  3. View the page and inspect the generated CSS.
  4. Confirm that no empty blockGap CSS rules are present.

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@devansh016 devansh016 marked this pull request as ready for review September 7, 2025 05:23
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 7, 2025

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin, New Block.
  • Labels found: [Type] Bug, [Type] Code Quality, Global Styles.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 7, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: devansh016 <devansh2002@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@shail-mehta shail-mehta added [Type] Bug An existing feature does not function as intended [Type] Code Quality Issues or PRs that relate to code quality Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Sep 7, 2025
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 [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants